Python virtualenv pyvenv pyenv pipenv poetry

Voir :

https://linuxfr.org/news/python-partie-7-environnements-virtuels

https://docs.python.org/fr/3/tutorial/venv.html

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

http://sametmax.com/les-environnement-virtuels-python-virtualenv-et-virtualenvwrapper/

https://makina-corpus.com/blog/metier/2015/bien-configurer-son-environnement-de-developpement-python

https://medium.com/python-pandemonium/better-python-dependency-and-package-management-b5d8ea29dff1

https://jacobian.org/2010/jul/20/when-pypi-goes-down/

poetry

pyvenv

Remplacé par python3 -m venv

pyvenv plop cd plop source bin/activate pip install --upgrade pip #deactivate
pyvenv cd env/ cd .. source env/bin/activate pip install -r requirements.txt
python3 -m venv plop source plop/bin/activate

pipenv

Source : http://sametmax.com/pipenv-solution-moderne-pour-remplacer-pip-et-virtualenv/

Préciser la version de Python à utiliser

python2	--two
python3	--three

Install via PIP

python3 -m pip install pip --upgrade --user python3 -m pip install pipenv --user

Install via apt

apt-get install pipenv

Exemple

pipenv run python pipenv shell pipenv install --dev
# Créer le fichier des dépendances pipenv lock # Installer toutes les dépendances pipenv install

Afficher les dépendances

pipenv graph

Chemin du dossier du virtualenv

pipenv --venv

Pb

AttributeError: module 'pip' has no attribute 'get_installed_distributions'

$ pipenv check
Checking PEP 508 requirements…
Passed!
Checking installed package safety…
An error occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/__main__.py", line 8, in <module>
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/click/core.py", line 722, in __call__
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/click/core.py", line 697, in main
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/click/core.py", line 1066, in invoke
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/click/core.py", line 895, in invoke
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/click/core.py", line 535, in invoke
File "/usr/lib/python3/dist-packages/pipenv/patched/safety.zip/safety/cli.py", line 52, in check
AttributeError: module 'pip' has no attribute 'get_installed_distributions'

Solution

sudo apt-get -y autoremove --purge pipenv python3-virtualenv-clone

$ python3 -m pip install pip --upgrade --user
$ python3 -m pip install pipenv --user