How to update Python pip?
Asked Answered
D

4

18

I've had to install Python packages and libraries using pip, but every time I do, it says I'm using an older version of pip, and that v18.1 is available by running the command

python -m pip install --upgrade pip

When I run this command, it just says the same thing. It apparently can't update itself because it's outdated. Is there any way to get around this, maybe by manually updating it?

Thanks in advance, community!

Update: The OS I'm using is currently Windows 10 and Python 3.6.4. The following screenshot is what outputs when running the command.

enter image description here

Disloyalty answered 25/10, 2018 at 15:3 Comment(7)
Which operating system are you using? I also assume you're using python 2.7 and its pip, can you please confim?Dissolution
What version of python are you using? Maybe a fresh install of python would do the trick?Piercy
If you have both python 2 and 3 installed, it’s possible that you’re only updating pip for the python2 install. You could try pip3 install —upgrade pipIsidore
"it just says the same thing" - would be helpful if you included just what exactly it says in your question.Lekishalela
Open the command prompt as administrator.Goodlooking
Are you an admin? This is a perms issue: your command should work, you just have to run it as an admin. If you're not an admin, you could try to do a wonky user level install of pip (which is both exciting and confusing and I'm not entirely sure it works b/c I've never done it)Blackguardly
Thanks, @Goodlooking and Matt! Running the update command as admin seems to have worked. Now I have to see if the Python program I have to run actually works.Disloyalty
D
33

Upgrading pip

On Linux or macOS:

pip install -U pip

On Windows:

python -m pip install -U pip
Dissolution answered 25/10, 2018 at 15:5 Comment(10)
I'm on Windows. Nope, that command seems to be the same thing as the "python -m pip install --upgrade pip" command. It still says the same thing.Disloyalty
@caleb did you try running the command from an elevated prompt?Dissolution
An elevated prompt? I'm not sure what that would be, and I'm not sure if it would solve the problem of pip not being able to update itself. The error didn't say it needed any extra permissions or anything.Disloyalty
In order to open an elevated prompt you have to right click on the "Command Prompt" aplication and choose "Run as administrator". Please try this and report results while I also investigate for other possible solutions.Dissolution
Oh, so basically running as administrator. I don't know if I tried running this command with that yet, so I'll try it.Disloyalty
Perfect, @CalebHawn! Please report results so we can keep fighting, if needed.Dissolution
Sorry it took so long, @Pitto! I've been busy with school. Running the command as administrator seems to have worked! Now I'm having a problem with the module I'm supposed to have installed. I'm trying to use pip to install the Discord.py module with "pip install discord.py" which says it installed fine, but the "import discord" statement reports a module not found error. Not sure what to do here, or if it's even related.Disloyalty
I am very happy to read that this solved your problem. In this case, please, upvote the question and / or mark it as the resolution. For the new question I suggest you to open a new question. I'd think that you can try pip install discord, for starters.Dissolution
this doesn't work for me...I get into a circular error: (automl-meta-learning) [miranda9@golubh1 automl-proj]$ pip install -U pip Traceback (most recent call last): File "/home/miranda9/.local/bin/pip", line 5, in <module> from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip._internal.cli.main'Ole
why does one need the -m flag in windows?Ole
J
5

Try with "python -m pip install --upgrade pip --user" It worked with me and I am with Win10.

Jamarjamb answered 25/10, 2019 at 8:30 Comment(1)
Worked for me as well, thanks! OS specs: Edition >> Windows 10 Pro; Version >> 21H2; Installed on >> ‎3/‎12/‎2021; OS build >> 19044.1766; Experience >> Windows Feature Experience Pack 120.2212.4180.0. Python specs: 3.9.13.Nymphalid
B
3

If you are on linux try this -

sudo su root

apt-get purge -y python-pip

wget https://bootstrap.pypa.io/get-pip.py

python ./get-pip.py

apt-get install python-pip

or

sudo -H pip3 install --upgrade pip
sudo -H pip2 install --upgrade pip
Barn answered 25/10, 2018 at 15:7 Comment(1)
Sorry, I'm currently trying it on Windows. I'm thinking of doing it on Linux instead, tho.Disloyalty
T
2

On OS X this worked for me

python -m pip install --upgrade pip
Thibaud answered 1/4, 2021 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.