2
2
Installing Sphinx
3
3
=================
4
4
5
- .. contents ::
6
- :depth: 1
5
+ Sphinx is a Python application. It can be installed in one of the ways described
6
+ below.
7
+
8
+ .. contents :: Installation methods
9
+ :depth: 2
7
10
:local:
8
11
:backlinks: none
9
12
10
13
.. highlight :: console
11
14
12
- Overview
13
- --------
15
+ After installation, you can check that Sphinx available by running ::
16
+
17
+ $ sphinx-build --version
18
+
19
+ This should print out the Sphinx version number.
20
+
21
+
22
+ .. tip ::
23
+
24
+ If you use Sphinx for documenting a Python library or application, it is
25
+ generally recommended to install Sphinx into your development environment (
26
+ `venv <https://docs.python.org/3/library/venv.html >`_ or
27
+ `conda <https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#creating-environments >`_
28
+ environment).
29
+
30
+ By adding Sphinx and 3rdparty extensions or themes that you use to your dev
31
+ dependencies, you make sure that you have a consistent setup for building
32
+ your documentation.
33
+
34
+
35
+ .. _install-pypi :
36
+
37
+ PyPI package
38
+ ------------
39
+
40
+ Sphinx packages are published on the `Python Package Index
41
+ <https://pypi.org/project/Sphinx/> `_ (PyPI). The preferred tool for installing
42
+ packages from *PyPI * is :command: `pip `, which is included in all modern versions of
43
+ Python.
44
+
45
+ On Linux or MacOS, you should open your terminal and run the following command.
46
+
47
+ ::
48
+
49
+ $ pip install -U sphinx
50
+
51
+ On Windows, you should open *Command Prompt * (:kbd: `⊞Win - r ` and type
52
+ :command: `cmd `) and run the same command.
53
+
54
+ .. code-block :: doscon
55
+
56
+ C:\> pip install -U sphinx
57
+
58
+ .. _install-conda :
59
+
60
+ Conda package
61
+ -------------
62
+ To work with :command: `conda `, you need a conda-based Python distribution such as
63
+ `anaconda `__, `miniconda `__, `miniforge `__ or `micromamba `__.
64
+
65
+ __ https://docs.anaconda.com/anaconda/
66
+ __ https://docs.anaconda.com/miniconda/
67
+ __ https://github.com/conda-forge/miniforge/
68
+ __ https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html
69
+
70
+
71
+ Sphinx is available both via the *anaconda main * channel (maintained by Anaconda Inc.)
72
+
73
+ ::
74
+
75
+ $ conda install sphinx
14
76
15
- Sphinx is written in `Python `__ and supports Python 3.9+. It builds upon the
16
- shoulders of many third-party libraries such as `Docutils `__ and `Jinja `__,
17
- which are installed when Sphinx is installed.
77
+ as well as via the *conda-forge * community channel ::
18
78
19
- __ https://docs.python-guide.org/
20
- __ https://docutils.sourceforge.io/
21
- __ https://jinja.palletsprojects.com/
79
+ $ conda install -c conda-forge sphinx
22
80
81
+ OS-specific package manager
82
+ ---------------------------
83
+
84
+ You may install a global version of Sphinx into your system using OS-specific package
85
+ managers. However, be aware that this is less flexible and you may run into
86
+ compatibility issues if you want to work across different projects.
23
87
24
88
Linux
25
- -----
89
+ ~~~~~
26
90
27
91
Debian/Ubuntu
28
- ~~~~~~~~~~~~~
92
+ """""""""""""
29
93
30
94
Install either ``python3-sphinx `` using :command: `apt-get `:
31
95
@@ -36,7 +100,7 @@ Install either ``python3-sphinx`` using :command:`apt-get`:
36
100
If it not already present, this will install Python for you.
37
101
38
102
RHEL, CentOS
39
- ~~~~~~~~~~~~
103
+ """"""""""""
40
104
41
105
Install ``python-sphinx `` using :command: `yum `:
42
106
@@ -47,7 +111,7 @@ Install ``python-sphinx`` using :command:`yum`:
47
111
If it not already present, this will install Python for you.
48
112
49
113
Other distributions
50
- ~~~~~~~~~~~~~~~~~~~
114
+ """""""""""""""""""
51
115
52
116
Most Linux distributions have Sphinx in their package repositories. Usually
53
117
the package is called ``python3-sphinx ``, ``python-sphinx `` or ``sphinx ``. Be
@@ -57,17 +121,15 @@ a speech recognition toolkit (*CMU Sphinx*) and a full-text search database
57
121
58
122
59
123
macOS
60
- -----
124
+ ~~~~~
61
125
62
- Sphinx can be installed using `Homebrew `__, `MacPorts `__, or as part of
63
- a Python distribution such as `Anaconda `__.
126
+ Sphinx can be installed using `Homebrew `__, `MacPorts `__.
64
127
65
128
__ https://brew.sh/
66
129
__ https://www.macports.org/
67
- __ https://www.anaconda.com/download
68
130
69
131
Homebrew
70
- ~~~~~~~~
132
+ """"""""
71
133
72
134
::
73
135
@@ -78,7 +140,7 @@ For more information, refer to the `package overview`__.
78
140
__ https://formulae.brew.sh/formula/sphinx-doc
79
141
80
142
MacPorts
81
- ~~~~~~~~
143
+ """"""""
82
144
83
145
Install either ``python3x-sphinx `` using :command: `port `:
84
146
@@ -97,23 +159,15 @@ For more information, refer to the `package overview`__.
97
159
98
160
__ https://www.macports.org/ports.php?by=library&substr=py39-sphinx
99
161
100
- Anaconda
101
- ~~~~~~~~
102
-
103
- ::
104
-
105
- $ conda install sphinx
106
-
107
162
Windows
108
- -------
163
+ ~~~~~~~
109
164
110
- Sphinx can be install using `Chocolatey `__ or
111
- :ref: `installed manually <windows-other-method >`.
165
+ Sphinx can be install using `Chocolatey `__.
112
166
113
167
__ https://chocolatey.org/
114
168
115
169
Chocolatey
116
- ~~~~~~~~~~
170
+ """"""""""
117
171
118
172
::
119
173
@@ -127,88 +181,6 @@ For more information, refer to the `chocolatey page`__.
127
181
128
182
__ https://chocolatey.org/packages/sphinx/
129
183
130
- .. _windows-other-method :
131
-
132
- Other Methods
133
- ~~~~~~~~~~~~~
134
-
135
- Most Windows users do not have Python installed by default, so we begin with
136
- the installation of Python itself. To check if you already have Python
137
- installed, open the *Command Prompt * (:kbd: `⊞Win - r ` and type :command: `cmd `).
138
- Once the command prompt is open, type :command: `python --version ` and press
139
- Enter. If Python is installed, you will see the version of Python printed to
140
- the screen. If you do not have Python installed, refer to the `Hitchhikers
141
- Guide to Python's `__ Python on Windows installation guides. You must install
142
- `Python 3 `__.
143
-
144
- Once Python is installed, you can install Sphinx using :command: `pip `. Refer
145
- to the :ref: `pip installation instructions <install-pypi >` below for more
146
- information.
147
-
148
- __ https://docs.python-guide.org/
149
- __ https://docs.python-guide.org/starting/install3/win/
150
-
151
-
152
- .. _install-pypi :
153
-
154
- Installation from PyPI
155
- ----------------------
156
-
157
- Sphinx packages are published on the `Python Package Index
158
- <https://pypi.org/project/Sphinx/> `_. The preferred tool for installing
159
- packages from *PyPI * is :command: `pip `. This tool is provided with all modern
160
- versions of Python.
161
-
162
- On Linux or MacOS, you should open your terminal and run the following command.
163
-
164
- ::
165
-
166
- $ pip install -U sphinx
167
-
168
- On Windows, you should open *Command Prompt * (:kbd: `⊞Win - r ` and type
169
- :command: `cmd `) and run the same command.
170
-
171
- .. code-block :: doscon
172
-
173
- C:\> pip install -U sphinx
174
-
175
- After installation, type :command: `sphinx-build --version ` on the command
176
- prompt. If everything worked fine, you will see the version number for the
177
- Sphinx package you just installed.
178
-
179
- Installation from *PyPI * also allows you to install the latest development
180
- release. You will not generally need (or want) to do this, but it can be
181
- useful if you see a possible bug in the latest stable release. To do this, use
182
- the ``--pre `` flag.
183
-
184
- ::
185
-
186
- $ pip install -U --pre sphinx
187
-
188
- Using virtual environments
189
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
190
-
191
- When installing Sphinx using pip,
192
- it is highly recommended to use *virtual environments *,
193
- which isolate the installed packages from the system packages,
194
- thus removing the need to use administrator privileges.
195
- To create a virtual environment in the ``.venv `` directory,
196
- use the following command.
197
-
198
- ::
199
-
200
- $ python -m venv .venv
201
-
202
- .. seealso :: :mod:`venv` -- creating virtual environments
203
-
204
- .. warning ::
205
-
206
- Note that in some Linux distributions, such as Debian and Ubuntu,
207
- this might require an extra installation step as follows.
208
-
209
- .. code-block :: console
210
-
211
- $ apt-get install python3-venv
212
184
213
185
Docker
214
186
------
@@ -252,6 +224,20 @@ For more details, please read `README file`__ of docker images.
252
224
.. __ : https://hub.docker.com/r/sphinxdoc/sphinx
253
225
254
226
227
+ Installation of the latest development release
228
+ ----------------------------------------------
229
+
230
+ You can install the latest development from *PyPI * using the ``--pre `` flag::
231
+
232
+ $ pip install -U --pre sphinx
233
+
234
+ .. warning ::
235
+
236
+ You will not generally need (or want) to do this, but it can be
237
+ useful if you see a possible bug in the latest stable release.
238
+
239
+
240
+
255
241
Installation from source
256
242
------------------------
257
243
0 commit comments