Outils pour utilisateurs

Outils du site


tech:python_virtualenv_pyvenv_pyenv_pipenv

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:python_virtualenv_pyvenv_pyenv_pipenv [2026/05/05 15:21] Jean-Baptistetech:python_virtualenv_pyvenv_pyenv_pipenv [2026/05/30 21:58] (Version actuelle) Jean-Baptiste
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon Code Python}}
 +
 +# 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
 +
 +Voir uv : remplace pip, pipx, poetry, pyenv :
 +* https://blog.stephane-robert.info/docs/developper/programmation/python/uv/
 +* [uv](https://docs.astral.sh/uv/)
 +
 +
 +## pyvenv
 +
 +**Remplacé par `python3 -m venv`**
 +
 +~~~bash
 +pyvenv plop
 +cd plop
 +source bin/activate
 +pip install --upgrade pip
 +#deactivate
 +~~~
 +
 +
 +~~~bash
 +pyvenv
 +cd env/
 +cd ..
 +source env/bin/activate
 +pip install -r requirements.txt 
 +~~~
 +
 +~~~bash
 +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
 +~~~bash
 +python3 -m pip install pip --upgrade --user
 +python3 -m pip install pipenv --user
 +~~~
 +
 +Install via apt
 +~~~bash
 +apt-get install pipenv
 +~~~
 +
 +Exemple
 +~~~bash
 +pipenv run python
 +pipenv shell
 +pipenv install --dev
 +~~~
 +
 +~~~bash
 +# Créer le fichier des dépendances
 +pipenv lock
 +
 +# Installer toutes les dépendances
 +pipenv install
 +~~~
 +
 +Afficher les dépendances
 +~~~bash
 +pipenv graph
 +~~~
 +
 +Chemin du dossier du virtualenv
 +~~~bash
 +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
 +
 +~~~bash
 +sudo apt-get -y autoremove --purge pipenv python3-virtualenv-clone
 +~~~
 +
 +~~~
 +$ python3 -m pip install pip --upgrade --user
 +$ python3 -m pip install pipenv --user
 +~~~
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki