PyTorch Sphinx Theme
raw JSON → 0.4.9 verified Fri May 01 auth: no python
PyTorch Sphinx Theme is a Sphinx theme used in PyTorch documentation. The current version is 0.4.9, with release cadence on demand. It provides a consistent look and feel for PyTorch-related documentation projects.
pip install pytorch-sphinx-theme Common errors
error pytorch_sphinx_theme.get_html_theme_path() AttributeError: module 'pytorch_sphinx_theme' has no attribute 'get_html_theme_path' ↓
cause The function get_html_theme_path was removed in newer versions (0.4.x) or may not be available.
fix
Use html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()] only for older versions; for 0.4.x, set html_theme = 'pytorch_sphinx_theme' and let Sphinx handle the path automatically.
error ModuleNotFoundError: No module named 'pytorch_sphinx_theme' ↓
cause You installed 'pytorch-sphinx-theme' but the import path is 'pytorch_sphinx_theme' (hyphen vs underscore). It's correct; if the error persists, reinstall the package.
fix
pip install pytorch-sphinx-theme # installs the package; import as pytorch_sphinx_theme
error Theme 'pytorch_sphinx_theme' not found ↓
cause The html_theme is set incorrectly or the theme is not installed in the Sphinx environment.
fix
Ensure you have installed pytorch-sphinx-theme and set html_theme = 'pytorch_sphinx_theme' (underscores).
Warnings
gotcha Do not use 'pytorch-sphinx-theme' in html_theme; use the string 'pytorch_sphinx_theme' (underscores, not hyphens). ↓
fix Set html_theme = 'pytorch_sphinx_theme'.
deprecated The package 'pytorch-sphinx-theme' was renamed from 'pytorch_sphinx_theme' on PyPI. The import remains 'pytorch_sphinx_theme', but ensure you install the correct package. ↓
fix Install 'pytorch-sphinx-theme' from PyPI.
gotcha The theme requires Sphinx >= 1.6, but some features may not work with Sphinx >= 4.0 without additional configuration. ↓
fix Check compatibility with your Sphinx version.
Imports
- PyTorchSphinxTheme
from pytorch_sphinx_theme import __version__
Quickstart
# conf.py
import pytorch_sphinx_theme
html_theme = 'pytorch_sphinx_theme'
html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()]