Aller au contenu

Python

Python 3 est installé par défaut:

Python3
$ python -V
Python 3.8.8

$ which python
/bin/python

# Les modules sont installés là: 
# /usr/lib/python3.8/site-packages
# /volume1/homes/bruno/.local/lib/python3.8/site-packages

$ find / -iname "site-packages" -type d -print 2>/dev/null

Python 2 est aussi installé:

Python2
$ python2 -V
Python 2.7.18

$ which python2
/usr/local/bin/python2

# Les modules sont installés là: 
# /usr/local/lib/python2.7/site-packages

pip n'est pas installé par défaut

Installer pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python3 get-pip.py
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
  Using cached pip-21.1.3-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  WARNING: The scripts pip, pip3 and pip3.8 are installed in '/var/services/homes/bruno/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.1.3

# Ajouter /volume1/homes/bruno/.local/bin au $PATH

# Utiliser sudo pour une install globale
Chemins en installation locale
which pip3
/var/services/homes/bruno/.local/bin/pip3

bruno@DS916:~/.local/bin $ pip --version
bruno@DS916:~/.local/bin $ pip3 --version
pip 21.1.3 from /var/services/homes/bruno/.local/lib/python3.8/site-packages/pip (python 3.8)

Mieux vaut créer un environnement virtuel:

Création de l'environnement virtuel
bruno@DS916:~/venv $ python3 -m venv mkdocs
Activation
bruno@DS916:~/venv $ source mkdocs/bin/activate
Mise-à-jour de pip et setuptools
(mkdocs) bruno@DS916:~/venv $ pip3 install -U pip setuptools
Installation de mkdocs
(mkdocs) bruno@DS916:~/venv $ pip3 install -U mkdocs
Dé-activation
(mkdocs) bruno@DS916:~/venv $ deactivate
Version de mkdocs
/var/services/homes/bruno/venv/mkdocs/bin/mkdocs --version
mkdocs, version 1.2.1 from /volume1/homes/bruno/venv/mkdocs/lib/python3.8/site-packages/mkdocs (Python 3.8)

Dernière mise à jour: March 4, 2022