I keep getting a message to upgrade pip

41,741

Solution 1

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.)

Solution 2

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

Solution 3

Update pip from a bat file:

call .\venv\Scripts\activate
py -m pip install --upgrade pip
call deactivate

Or if you are in VS Code integrated Terminal

& venv/Scripts/activate.ps1
py -m pip install --upgrade pip
Share:
41,741

Related videos on Youtube

Maxim
Author by

Maxim

Updated on August 17, 2020

Comments

  • Maxim
    Maxim almost 4 years

    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.

    • GetHacked
      GetHacked almost 6 years
      Where are you running the command to reinstall pip? And where is the message appearing? pip may need to be updated in your venv, but you're trying to update in another enviornment
    • Maxim
      Maxim almost 6 years
      @Dyno I guess there are two ways to answer that. 1. I ran on windows inside a cmd prompt. 2. Inside the venv after it has been activated.
    • Maxim
      Maxim almost 6 years
      This message does not show up when I install outside of a venv.
    • phd
      phd almost 6 years
    • Evgeny
      Evgeny almost 6 years
      I get this message all the time and cannnot upgrade, would be nice to see why and a solution.
    • georgexsh
      georgexsh over 5 years
      your virtualenv binary is likely belonged to another python installation, use virtualenv -v venv to check the detail.
    • James Lim
      James Lim over 5 years
      @Maksim pretty certain that the issue here is that the version of pip packaged with virtualenv is outdated.
  • Maxim
    Maxim over 5 years
    By multiple python environments are you talking about the virtual ones or the python installations themselves?
  • wowkin2
    wowkin2 over 5 years
    Both. Looks like you installed Python to some custom directory. I prefer to install it to a folder like: `C:\Python36`. So every time I see where all versions are and able to uninstall it. And preferable way is to use mostly python from virtualenv, not root.
  • wowkin2
    wowkin2 over 5 years
    @Maksim, try to uninstall Python completely and install the newest version. After create new virtual environments for your projects.
  • Maxim
    Maxim over 5 years
    that still didn't fix my problem. Unless I didn't uninstall correctly, but that was a bit confusing. I also don't want to use a large IDE, I'm fine with IDLE.
  • Maxim
    Maxim over 5 years
    Thanks for your thorough reply. In regards to the commands you had me run everything points to my 3.6 version of python and doing pip list shows that my pip is 18.0. Seems like the venv command is using a different version. Is that possible?
  • Maxim
    Maxim over 5 years
    Also: $ python -m pip install -U pip just returns Requirement already up-to-date: pip in c:\users\mkupfer\appdata\local\programs\p ython\python36-32\lib\site-packages (18.0)
  • Maxim
    Maxim over 5 years
    This is not the type of solution I'm looking for. I would rather have things working correctly than to create a workaround script.
  • wowkin2
    wowkin2 over 5 years
    Had you another version of Python on the same PC? For example 2.7?
  • Maxim
    Maxim over 5 years
    So virtualenv was on version 15.1.0. I updated to 16.0.0 but still having old version of pip. pip list shows that I'm still on pip (9.0.1)
  • James Lim
    James Lim over 5 years
    Did you create new virtual environment, and verify that the version of pip, in that new virtual environment, is at 9.0.1? Is that is the case, then the release notes for virtualenv are wrong. Also, have you looked inside virtualenv_support?
  • Maxim
    Maxim over 5 years
    I did notice that I have a pipenv 9.0.3. Does that need to be removed/updated?
  • Maxim
    Maxim over 5 years
    yes I created a new venv --> activated it --> ran pip list
  • James Lim
    James Lim over 5 years
    What command are you using to create the virtualenv? Make sure you run virtualenv --version, then run virtualenv venv. For now, don't use pipenv, to simplify the problem.
  • James Lim
    James Lim over 5 years
  • Admin
    Admin over 5 years
    Will this ever truly solve the problem? Won't OP just have to redo this step once virtualenv is updated or am I missing something?
  • James Lim
    James Lim over 5 years
    If you update /path/to/site-packages/virtualenv_support/, all new virtualenvs will use the new pip that you installed there.
  • Admin
    Admin over 4 years
    @Maksim apologies, I has assumed that you may have been creating a virtualenv from a script, and therefore may have had the luxury of adding a line or two of code.
  • above_c_level
    above_c_level almost 4 years
    Please don't repost answers. If an answer was helpful, please upvote the answer.
  • Ghasem Tabatabaei
    Ghasem Tabatabaei almost 3 years
    I used "pip install --upgrade pip" and it works....