How do I update/upgrade pip itself from inside my virtual environment?


I’m able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version.

What’s the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I’ve already tried pip update and pip update pip with no success.

Asked By: zakdances



pip is just a PyPI package like any other; you could use it to upgrade itself the same way you would upgrade any package:

pip install --upgrade pip

On Windows the recommended command is:

py -m pip install --upgrade pip
Answered By: Cairnarvon

The more safe method is to run pip though a python module:

python -m pip install -U pip

On windows there seem to be a problem with binaries that try to replace themselves, this method works around that limitation.

Answered By: Janusz Skonieczny

In my case this worked from the terminal command line in Debian Stable

python3 -m pip install --upgrade pip
Answered By: Prabhakaran KC

In my case my pip version was broken so the update by itself would not work.


(inside virtualenv):easy_install -U pip
Answered By: jmoz

I tried all of these solutions mentioned above under Debian Jessie. They don’t work, because it just takes the latest version compile by the debian package manager which is 1.5.6 which equates to version 6.0.x. Some packages that use pip as prerequisites will not work as a results, such as spaCy (which needs the option –no-cache-dir to function correctly).

So the actual best way to solve these problems is to run downloaded using wget, from the website or using curl as follows:

 wget -O ./
 python ./
 python3 ./

This will install the current version which at the time of writing this solution is 9.0.1 which is way beyond what Debian provides.

 $ pip --version
 pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python2.7/dist-packages (python 2.7)
 $ pip3 --version
 pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python3.4/site-packages (python 3.4)
Answered By: Eamonn Kenny

To get this to work for me I had to drill down in the Python directory using the Python command prompt (on WIN10 from VS CODE). In my case it was in my AppDataLocalProgramsPythonpython35-32 directory. From there now I ran the command…

python -m pip install --upgrade pip

This worked and I’m good to go.

Answered By: Sean

I had installed Python in C:PythonPython36 so I went to the Windows command prompt and typed cd C:PythonPython36 to get to the right directory. Then entered the python -m install --upgrade pip all good!

Answered By: Walt

On my lap-top with Windows 7 the right way to install latest version of pip is:

python.exe -m pip install --upgrade pip
Answered By: MiloshB

Open Command Prompt with Administrator Permissions, and repeat the command:

python -m pip install --upgrade pip
Answered By: MRamzan

pip version 10 has an issue. It will manifest as the error:

ubuntu@mymachine-:~/mydir$ sudo pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

The solution is to be in the venv you want to upgrade and then run:

sudo myvenv/bin/pip install --upgrade pip

rather than just

sudo pip install --upgrade pip
Answered By: Calaf

Single Line Python Program
The best way I have found is to write a single line program that downloads and runs the official get-pip script. See below for the code.

The official docs recommend using curl to download the get-pip script, but since I work on windows and don’t have curl installed I prefer using python itself to download and run the script.

Here is the single line program that can be run via the command line using Python 3:

python -c "import urllib.request; exec(urllib.request.urlopen('').read())"

This line gets the official “” script as per the installation notes and executes the script with the “exec” command.

For Python2 you would replace “urllib.request” with “urllib2”:

python -c "import urllib2; exec(urllib2.urlopen('').read())"

It’s worth noting that running any python script blindly is inherently dangerous. For this reason, the official instructions recommend downloading the script and inspecting it before running.

That said, many people don’t actually inspect the code and just run it. This one-line program makes that easier.

Answered By: FistOfFury

I had a similar problem on a raspberry pi.

The problem was that http requires SSL and so I needed to force it to use https to get around this requirement.

sudo pip install --upgrade pip --index-url=


sudo pip-3.2 --upgrade pip --index-url=
Answered By: user391339

Upgrading pip using ‘pip install –upgrade pip‘ does not always work because of the dreaded cert issue: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version

I like to use the one line command for virtual envs:

curl | python -

Or if you want to install it box wide you will need

curl | sudo python -

you can give curl a -s flag if you want to silence the output when running in an automation script.

Answered By: rouble

In case you are using venv any update to pip install will result in upgrading the system pip instead of the venv pip. You need to upgrade the pip bootstrapping packages as well.

python3 -m pip install --upgrade pip setuptools wheel
Answered By: dre-hh

I was in a similar situation and wanted to update urllib3 package.
What worked for me was:

pip3 install --upgrade --force-reinstall --ignore-installed urllib3==1.25.3
Answered By: Avik Aggarwal

for windows,

  • go to command prompt
  • and use this command
  • python -m pip install -–upgrade pip
  • Dont forget to restart the editor,to avoid any error
  • you can check the version of the pip by
  • pip --version
  • if you want to install any particular version of pip , for example version 18.1 then use this command,
  • python -m pip install pip==18.1
Answered By: Rohan Devaki

First, do this:

sudo apt install python3-pip python-setuptools-doc

Then, as a non-root user (NEVER, never run pip* as root!):

# N.B. bash shell works for this, I have never tested with other shells!
. ....your_virtualenv_folder/bin/activate
pip3 install -U pip

Note: -U is a synonym for --upgrade, as far as I know.

For linux

python3 -m pip install --upgrade pip

For windows:

  1. Type Command Prompt in the Windows search box

  2. In the Command Prompt, type cd

  3. Press Enter, and you’ll see the drive name C:>

  4. Locate your Python application path, which is the folder where you originally installed Python

    Here is an example of a Python application path:

  5. Once you retrieved the Python application path, type the following command in the Command Prompt:

    cd followed by your Python application path

    For our example:

    C:>cd C:UsersRonAppDataLocalProgramsPythonPython39
  6. Press Enter

  7. Type python -m pip install --upgrade pip and press Enter

Answered By: Dev
pip install --upgrade pip

In UBUNTU 18.04 I got the following error when I execute the above command:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/bin/pip'
Consider using the `--user` option or check the permissions.

The below command solves my problem:

pip install --upgrade pip --user
Answered By: Hasinur

Head to your command prompt and type the following:

python -m pip install --upgrade pip

In linux

I will update with this code

sudo -H pip3 install --upgrade pip
Answered By: Netwons

While updating pip in virtual env use full path in python command

Envirnments folder struture


h:folderNamemyenvscriptspython -m pip install --upgrade pip

Answered By: Sumit Asagaonkar
some_venv>python.exe -m install --upgrade pip
some_venv>pip -V
Answered By: True Explorer