I usually just run the following commands to upgrade both pip2 (=pip by default) and pip3:
sudo -H pip3 install --upgrade pip
sudo -H pip2 install --upgrade pip
You must make sure that you upgrade the version (for Python 2 or 3), which you want to react on the command pip without number, last.
Also please note that this keeps the old packaged versions installed through apt-get or any other package manager, but adds new versions which have nothing to do with the system packages. The pip-installed packages will be preferred, but you should not remove the apt-get-installed ones either, because the package manager can't know that any pip version is installed otherwise.
I usually just run the following commands to upgrade both pip2 (=pip by default) and pip3:
sudo -H pip3 install --upgrade pip
sudo -H pip2 install --upgrade pip
You must make sure that you upgrade the version (for Python 2 or 3), which you want to react on the command pip without number, last.
Also please note that this keeps the old packaged versions installed through apt-get or any other package manager, but adds new versions which have nothing to do with the system packages. The pip-installed packages will be preferred, but you should not remove the apt-get-installed ones either, because the package manager can't know that any pip version is installed otherwise.
I think the
pip install --upgrade pip
command does not work properly anymore. The correct command should be:
for Python 3:
python3 -m pip install --upgrade pipfor Python 2:
python2 -m pip install --upgrade pip
P.S. If you want to make sure your other Python packages are also up to date, follow the instructions here.
python - How should I upgrade pip on Ubuntu 14.04? - Stack Overflow
linux - How can I upgrade pip on Ubuntu 10.04? - Unix & Linux Stack Exchange
python - How to upgrade pip3? - Stack Overflow
Python Pip broken after updating...
Can I use `pip install --upgrade pip` to upgrade PIP?
Will upgrading PIP affect my existing Python packages?
Do I need to upgrade PIP for each Python version separately?
Videos
pip is just a PyPI package like any other; you could use it to upgrade itself the same way you would upgrade any package:
Copypip install --upgrade pip
On Windows the recommended command is:
Copypy -m pip install --upgrade pip
The more safe method is to run pip though a python module:
Copypython -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.
Here's my number one tip: Do not use sudo with pip. You don't need it.
Instead, use a user-level Python distribution installed via pyenv. That way you don't risk yourself messing around with system-level frameworks (and hence creating a problem removing dependencies etc.).
Install Pyenv
All you have to do is:
- Run the
pyenvinstaller - Follow the instructions
- Install the Python versions you need
- Choose which Python version you want to use for a given directory, or globally
For example, to install 3.7, check which versions are available:
pyenv install -l | grep 3.7
Then run:
pyenv install 3.7.4
Switch to the new version
Now, you can choose your Python version:
pyenv global 3.7.4
This switches your python to point to 3.7.4. If you want the “old” system python, run:
pyenv global system
To check which Python versions are available, run pyenv versions.
Upgrade pip
Once you've switched to a Pyenv version, you can run pip without sudo, and install/upgrade packages easily — without interfering with your system Python:
pyenv global 3.7.4
pip install --upgrade pip
pip install numpy
Do not use apt-get to update pip. The newest version of pip available through apt-get is old.
Quick solution:
As @kenorb is saying in the comments, you can upgrade pip using pip with sudo like this:
sudo pip install --upgrade pip
Proper solution:
Use pyenv - see the answer by @slhck
The most painless way that I found that works is to use install virtualenv and use pip inside a virtualenv. This does not even require you install pip at the system level (which you might have done by running sudo apt-get install python-pip):
sudo apt-get install python-virtualenv # install virtualenv
virtualenv venv # create a virtualenv named venv
source venv/bin/activate # activate virtualenv
pip install -U pip # upgrade pip inside virtualenv
Depending on the operating system you are using the steps differ somewhat:
On ubuntu you can do the following:
sudo apt install python3-pip
sudo pip3 install --upgrade pip setuptools
sudo apt update&& sudo apt upgrade python-pip
On windows:
c:\>pip install --upgrade pip setuptools
On Osx:
sudo pip3 install --upgrade pip setuptools
Remove your system wide installation of pip:
sudo apt-get purge python-pip
Then install a fresh copy of pip:
curl https://bootstrap.pypa.io/get-pip.py | sudo python
Tested on ubuntu 10.04 i686
I suggest you to use virtualenv. For further details see the Official pip documentation
As a matter of fact, pip install --upgrade pip does work, but it install a new pip, in my case pip-2.6. So the command to uninstall is pip-2.6 uninstall package-name.
You are using pip3 to install flask-script which is associated with python 3.5. However, you are trying to upgrade pip associated with the python 2.7, try running pip3 install --upgrade pip.
It might be a good idea to take some time and read about virtual environments in Python. It isn't a best practice to install all of your packages to the base python installation. This would be a good start: http://docs.python-guide.org/en/latest/dev/virtualenvs/
To upgrade your pip3, try running:
sudo -H pip3 install --upgrade pip
Your pip may move from /bin to /usr/local/bin
To upgrade pip as well, you can follow it by:
sudo -H pip2 install --upgrade pip