| 1 |
# MkDocs Installation |
| 2 |
|
| 3 |
A detailed guide. |
| 4 |
|
| 5 |
--- |
| 6 |
|
| 7 |
## Requirements |
| 8 |
|
| 9 |
MkDocs requires a recent version of [Python] and the Python package |
| 10 |
manager, [pip], to be installed on your system. |
| 11 |
|
| 12 |
You can check if you already have these installed from the command line: |
| 13 |
|
| 14 |
```console |
| 15 |
$ python --version |
| 16 |
Python 3.8.2 |
| 17 |
$ pip --version |
| 18 |
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) |
| 19 |
``` |
| 20 |
|
| 21 |
If you already have those packages installed, you may skip down to [Installing |
| 22 |
MkDocs](#installing-mkdocs). |
| 23 |
|
| 24 |
### Installing Python |
| 25 |
|
| 26 |
Install [Python] using your package manager of choice, or by downloading an |
| 27 |
installer appropriate for your system from [python.org] and running it. |
| 28 |
|
| 29 |
> NOTE: |
| 30 |
> If you are installing Python on Windows, be sure to check the box to have |
| 31 |
> Python added to your PATH if the installer offers such an option (it's |
| 32 |
> normally off by default). |
| 33 |
> |
| 34 |
>  |
| 35 |
|
| 36 |
### Installing pip |
| 37 |
|
| 38 |
If you're using a recent version of Python, the Python package manager, [pip], |
| 39 |
is most likely installed by default. However, you may need to upgrade pip to the |
| 40 |
lasted version: |
| 41 |
|
| 42 |
```bash |
| 43 |
pip install --upgrade pip |
| 44 |
``` |
| 45 |
|
| 46 |
If you need to install pip for the first time, download [get-pip.py]. |
| 47 |
Then run the following command to install it: |
| 48 |
|
| 49 |
```bash |
| 50 |
python get-pip.py |
| 51 |
``` |
| 52 |
|
| 53 |
## Installing MkDocs |
| 54 |
|
| 55 |
Install the `mkdocs` package using pip: |
| 56 |
|
| 57 |
```bash |
| 58 |
pip install mkdocs |
| 59 |
``` |
| 60 |
|
| 61 |
You should now have the `mkdocs` command installed on your system. Run `mkdocs |
| 62 |
--version` to check that everything worked okay. |
| 63 |
|
| 64 |
```console |
| 65 |
$ mkdocs --version |
| 66 |
mkdocs, version 1.2.0 from /usr/local/lib/python3.8/site-packages/mkdocs (Python 3.8) |
| 67 |
``` |
| 68 |
|
| 69 |
> NOTE: |
| 70 |
> If you would like manpages installed for MkDocs, the [click-man] tool can |
| 71 |
> generate and install them for you. Simply run the following two commands: |
| 72 |
> |
| 73 |
> ```bash |
| 74 |
> pip install click-man |
| 75 |
> click-man --target path/to/man/pages mkdocs |
| 76 |
> ``` |
| 77 |
> |
| 78 |
> See the [click-man documentation] for an explanation of why manpages are |
| 79 |
> not automatically generated and installed by pip. |
| 80 |
<!-- --> |
| 81 |
> NOTE: |
| 82 |
> If you are using Windows, some of the above commands may not work |
| 83 |
> out-of-the-box. |
| 84 |
> |
| 85 |
> A quick solution may be to preface every Python command with `python -m` |
| 86 |
> like this: |
| 87 |
> |
| 88 |
> ```bash |
| 89 |
> python -m pip install mkdocs |
| 90 |
> python -m mkdocs |
| 91 |
> ``` |
| 92 |
> |
| 93 |
> For a more permanent solution, you may need to edit your `PATH` environment |
| 94 |
> variable to include the `Scripts` directory of your Python installation. |
| 95 |
> Recent versions of Python include a script to do this for you. Navigate to |
| 96 |
> your Python installation directory (for example `C:\Python38\`), open the |
| 97 |
> `Tools`, then `Scripts` folder, and run the `win_add2path.py` file by double |
| 98 |
> clicking on it. Alternatively, you can download the [script][a2p] and run it |
| 99 |
> (`python win_add2path.py`). |
| 100 |
|
| 101 |
[Python]: https://www.python.org/ |
| 102 |
[python.org]: https://www.python.org/downloads/ |
| 103 |
[pip]: https://pip.readthedocs.io/en/stable/installing/ |
| 104 |
[get-pip.py]: https://bootstrap.pypa.io/get-pip.py |
| 105 |
[click-man]: https://github.com/click-contrib/click-man |
| 106 |
[click-man documentation]: https://github.com/click-contrib/click-man#automatic-man-page-installation-with-setuptools-and-pip |
| 107 |
[a2p]: https://github.com/python/cpython/blob/master/Tools/scripts/win_add2path.py |