Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I keep getting a message to upgrade pip

Tags:

Whenever I create a venv, I get a message asking me to upgrade pip. I run the command for upgrade, and it pops up again on another venv. How can I make this permanent.

Message:

You are using pip version 9.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. 

Update: Just received recommendation to read this possible duplicate answer: virtualenv use upgraded system default pip

This does not solve my issue though. Why?

My pip3 appears to already be up to date:

C:\Users\mkupfer\Python-Sandbox\sibc-python-scripts>pip --version pip 18.0 from c:\users\mkupfer\appdata\local\programs\python\python36-32\lib\sit e-packages\pip (python 3.6)  C:\Users\mkupfer\Python-Sandbox\sibc-python-scripts>pip3 --version pip 18.0 from c:\users\mkupfer\appdata\local\programs\python\python36-32\lib\sit e-packages\pip (python 3.6)  C:\Users\mkupfer\Python-Sandbox\sibc-python-scripts>pip3 install --upgrade pip Requirement already up-to-date: pip in c:\users\mkupfer\appdata\local\programs\p ython\python36-32\lib\site-packages (18.0) 

Solved

Solution: I was able to fix this altogether by using virtualenv to create a new virtual environment. Not sure if this is a bug in venv. I'll just use the package that works going forward. Thanks @James Lim for the answer.

like image 526
Maksim Avatar asked Aug 02 '18 01:08

Maksim


People also ask

Is it safe to upgrade pip?

New software releases can bring bug fixes, new features, and faster performance. For example, NumPy 1.20 added type annotations, and improved performance by using SIMD when possible. If you're installing NumPy, you might want to install the newest version.

How do I know if pip is updated?

How do you check if a PIP Package is Installed. To check if pip is already available on the system, the simplest way is to use the version option, and it will show the current version of the PIP package.

How does pip upgrade work?

If you want a newer pip version, then you'd need to first run ensurepip . Afterward, you can update pip manually to its latest version. Another way to fix your pip installation is to use the get-pip.py script. The get-pip.py file contains a full copy of pip as an encoded ZIP file.


2 Answers

The issue seems to be that new virtual environments are using an old version of pip. Note that pip is installed from a source tarfile (or wheel) included with virtualenv, in the site-packages/virtualenv_support directory.

$ ls -l /path/to/site-packages/virtualenv_support pip-9.1-py2.py3-none-any.whl 

A quick way to workaround the problem is to make sure you upgrade pip whenever you create a new virtualenv, like so:

$ virtualenv venv $ venv/bin/pip install -U pip 

Alternatively, make sure you have the latest version of virtualenv. According to their release notes, virtualenv==16 is using pip==10.

$ pip install -U virtualenv 

Finally, since virtualenv looks for pip*.whl in virtualenv_support, this will also work:

$ mv /path/to/site-packages/virtualenv_support/pip*.whl{,bak} $ pip wheel -w /path/to/site-packages/virtualenv_support/ 'pip==18' 

All new virtualenvs will use the version of pip that you installed into virtualenv_support. However, this feels hacky.

(Attempted with virtualenv==16. This results in all new virtualenvs with pip==18.)

like image 105
James Lim Avatar answered Sep 20 '22 21:09

James Lim


For me looks like you have multiple python environments and in one of them, there is not an upgraded pip. You have 2 options:

  • navigate to each of that folders and update each pip
  • you can remove all of them, reinstall and use virtualenv in future with correct pip
  • install some IDE (e.g. PyCharm) that can handle that automatically for you and show all issues visually
like image 31
wowkin2 Avatar answered Sep 20 '22 21:09

wowkin2