GNU/Linux >> Tutoriels Linux >  >> Debian

Python - La bonne façon de mettre à jour Pip dans Stretch Debian ?

J'ai lu quelques notes indiquant que ce n'est pas une bonne idée d'effectuer une mise à niveau pip à l'aide de la commande sudo. Ma question est que si je ne donne pas sudo, j'obtiens des erreurs d'autorisation. Comment puis-je résoudre ça? Aussi, quelle est la raison pour laquelle sudo n'est pas suggéré afin de mettre à jour pip ?

$python -m pip install --upgrade pip
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pip
  Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
  Rolling back uninstall of pip
  Moving to /home/abc/.local/bin/pip
   from /tmp/pip-uninstall-V4F8Pj/pip
  Moving to /home/abc/.local/bin/pip2
   from /tmp/pip-uninstall-V4F8Pj/pip2
  Moving to /home/abc/.local/bin/pip2.7
   from /tmp/pip-uninstall-V4F8Pj/pip2.7
  Moving to /home/abc/.local/lib/python2.7/site-packages/pip-19.2.3.dist-info/
   from /home/abc/.local/lib/python2.7/site-packages/~ip-19.2.3.dist-info
  Moving to /home/abc/.local/lib/python2.7/site-packages/pip/
   from /home/abc/.local/lib/python2.7/site-packages/~ip
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip-20.0.2.dist-info/top_level.txt'
Consider using the `--user` option or check the permissions.

WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Réponse acceptée :

Ne mettez jamais à niveau la version des outils fournie par le système d'exploitation en dehors du système de gestion des packages, car si un nouveau package est publié, il écrasera vos modifications.

Alors sudo pip install --upgrade pip est une mauvaise chose. Le système de package du système d'exploitation pense qu'il contrôle les fichiers et vous les avez remplacés. Un comportement étrange peut en résulter, y compris l'installation d'un ancien version que vous avez précédemment installée !

Si vous voulez une version plus récente, vous pouvez l'installer dans le profil utilisateur

% pip install --upgrade --user pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
    100% |################################| 1.4MB 615kB/s 
Installing collected packages: pip
Successfully installed pip-20.0.2

Cela installera la dernière version dans $HOME/.local/bin

% ls -l .local/bin/pip                                           
-rwxr-xr-x 1 sweh sweh 223 Feb 16 21:49 .local/bin/pip

Si vous avez $HOME/.local/bin sur votre PATH, vous récupérerez toujours les programmes installés par l'utilisateur pip.

La plupart du temps, cependant, vous n'avez pas besoin pour mettre à jour pip .


Debian
  1. Construire des noyaux Linux à la manière de Debian

  2. Comment mettre à niveau Debian 8 Jessie vers Debian 9 Stretch

  3. Comment changer la version python par défaut sur Debian 9 Stretch Linux

  4. Comment installer Pip sur Ubuntu 18.04, Debian 9 et Linux Mint 19

  5. Comment mettre à niveau Debian 8 vers Debian 9 Stretch

Comment mettre à niveau Debian 9 Stretch vers Debian 10 Buster

Comment mettre à jour Debian 8 Jessie vers Debian 9 Stretch

Mettre à niveau Debian 9 Stretch vers Debian 10 Buster à partir de la ligne de commande

Comment installer Pip sur Debian 9 Stretch

Comment installer Python 3.7 sur Debian 9 Stretch

Comment mettre à niveau Debian 9 Stretch vers Linux Debian 10 Buster