It seems python3-pip is not installed correctly on my system so I did
sudo apt install --reinstall python3-pip
Now I can install programs with pip3.
Answer from Jedi on askubuntu.comIt seems python3-pip is not installed correctly on my system so I did
sudo apt install --reinstall python3-pip
Now I can install programs with pip3.
These all failed for me, I had to run via a manual download:
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
I recently moved from Windows over to Ubuntu - running Ubuntu 20.04. Python version 3.8.10 - which I had to manually install using option 1 of the following doc: https://phoenixnap.com/kb/how-to-install-python-3-ubuntu
When I enter sudo apt install python3-pip in the terminal to install pip I get the following error. Notice the 404 errors and Failed to fetch errors. What am I doing wrong?
Thanks for the help and time.
Ign:1 http://mirror.lnx-solutions.com/ubuntu focal-updates/universe amd64 python-pip-whl all 20.0.2-5ubuntu1.6 Ign:2 http://mirror.lnx-solutions.com/ubuntu focal-updates/main amd64 python3-distutils all 3.8.10-0ubuntu1~20.04 Ign:3 http://mirror.lnx-solutions.com/ubuntu focal-updates/universe amd64 python3-pip all 20.0.2-5ubuntu1.6 Err:1 http://mirror.lnx-solutions.com/ubuntu focal-updates/universe amd64 python-pip-whl all 20.0.2-5ubuntu1.6 404 Not Found [IP: 41.76.131.62 80] Ign:2 http://mirror.lnx-solutions.com/ubuntu focal-updates/main amd64 python3-distutils all 3.8.10-0ubuntu1~20.04 Err:3 http://mirror.lnx-solutions.com/ubuntu focal-updates/universe amd64 python3-pip all 20.0.2-5ubuntu1.6 404 Not Found [IP: 41.76.131.62 80] Ign:2 http://mirror.lnx-solutions.com/ubuntu focal-updates/main amd64 python3-distutils all 3.8.10-0ubuntu1~20.04 Err:2 http://mirror.lnx-solutions.com/ubuntu focal-updates/main amd64 python3-distutils all 3.8.10-0ubuntu1~20.04 404 Not Found [IP: 41.76.131.62 80] E: Failed to fetch http://mirror.lnx-solutions.com/ubuntu/pool/universe/p/python-pip/python-pip-whl_20.0.2-5ubuntu1.6_all.deb 404 Not Found [IP: 41.76.131.62 80] E: Failed to fetch http://mirror.lnx-solutions.com/ubuntu/pool/main/p/python3-stdlib-extensions/python3-distutils_3.8.10-0ubuntu1~20.04_all.deb 404 Not Found [IP: 41.76.131.62 80] E: Failed to fetch http://mirror.lnx-solutions.com/ubuntu/pool/universe/p/python-pip/python3-pip_20.0.2-5ubuntu1.6_all.deb 404 Not Found [IP: 41.76.131.62 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
How to install pip in Python 3 on Ubuntu 18.04?
python3 - Difference between installing a package with 'apt' and 'pip' - Unix & Linux Stack Exchange
How to install pip for python3.13t
python - How to install python3 version of package via pip on Ubuntu? - Stack Overflow
How do we install pip3 in Python?
How can we install specific version of pip3 in Ubuntu?
How do we install sqlite3 with pip3 in Ubuntu?
Videos
Try this command
sudo apt-get install python3-pip
Note: If you have a fresh install, you need to do this first before trying the above command.
sudo apt-get update
Try the following commands:
Copysudo apt-get install python3-setuptools
sudo python3 -m easy_install install pip
python3 -m pip --version
I will appreciate if someone could explain the differences (if any) between:
Highest level: you never should use pip install to install to system (--system, or on Linux distros where --user isn't the default, omitting --user) when things might conflict with your system whereas apt install is pretty safe.
Explanation:
apt is the package installation tool of your Linux distro. A Linux distribution these days is mostly the effort to offer a way to install packages in a way that works with each other without breaking – for example, if you're trying to install a library that libreoffice uses, but in a version incompatible with your libreoffice, your linux distro tool will tell you that sadly, to fulfill your command, it will have to uninstall libreoffice, because it wouldn't work with that version you're requesting.
The fact that you very rarely see that happen is an indication of how well modern Linux distros are doing here: typically, most of software that you can install using apt works well together.
pip, on the other hand, has no notion of what other software you have on your machine, which you might need. You tell pip to install something in a version that breaks your ability to even boot your system – it will go ahead and do that.
pip is python-specific. It assumes that all there is on that machine that has something to do with Python is kind of "fair game" and can be dealt with arbitrarily. Frankly, that is almost never the case – for example, on Fedora (another Linux distro that you're not using), you can easily break the installation tool dnf (Fedora's apt, if you will) with pip.
So, why does pip still exist? Well, there are situation where it's OK for pip to assume every bit of python it sees is under its control: Python brings a mechanism called virtual environments. In these, no python modules are per se installed, and they don't conflict with other software on your machine – simply because other software isn't aware of the environment.
Using that is quite straightforward. You can set up such an environment using
python3 -m venv ~/bertsexperiment
That sets up a folder ~/bertsexperiment for Python stuff to be installed into. You can then, from anywhere you like, "activate" that environment (what that really does is just change a few environment variables) – but that only affects the current process and things started from it. Try it:
source ~/bertsexperiment/bin/activate
will set up this shell in a way that all future python tooling will work with that folder as "prefix".
For example, if you wanted to have an updated setuptools in that shell, you could, after sourceing the activaton script as shown above, run pip3 install --upgrade setuptools, and they would be installed into the virtualenv.
In short:
- if in doubt, use
apt, because it's your distro's job to keep your software stack working together - Never use
pipunless you intend to install something into a folder only used for your current project and not by anything else on your system.
Hence, the only realistic time you would want to use it is when you're using a Python virtualenv.
It really depends on your end goal.
- Something in another Debian package depends on this package? Definitely use
apt. - Or conversely, you want to create a package or a set of packages for Debian or a Debian-based distro like Ubuntu, Mint, etc - again, definitely stay in
aptland. - You want to install something which requires a newer version than you can find on Debian - you can hunt for backported
.debpackages from https://backports.debian.org/ or random PPAs, but perhaps at this point it's easier and more straightforward to move topip. (Though sometimes the packaging work adds significant value but requires nontrivial effort; then, a PPA can really save your day.) - You want to develop a Python script of your own and ideally have the latest and greatest features of the Python packages you depend on - usually then use
pip- ... or even install things directly from the upstream Github project or whatever, for the really bleeding edge. But probably don't stretch too far. If you don't have a professional software development team at your disposal, stick to reasonably stable versions for all but the most valuable, most crucial one or two packages you depend on.
To recap, what makes sense ultimately depends on where in the maturity cycle you are. The benefit of official Debian packages is that they tend to be very stable and time-tested, but the drawback is then that you will not be running the latest versions with the spiffiest new features.
Also keep in mind that some Debian packages go to extra lengths to integrate the packaged software with the broader Debian ecosystem. For a random Python script this is typically unimportant, but if it's a Debian system administration tool or some sort of infrastructure project, obviously you want all the Debian parts that upstream might not have, or might not enable and configure correctly by default.
One of three things will likely fix it:
In case
python3-pipdid not install correctly, re-install it:This is used for Debian-based distros like Ubuntu, Mint:
sudo apt-get remove python3-pip; sudo apt-get install python3-pipIf using Fedora, CentOS, RHEL, please use:
sudo dnf reinstall python3-pipTry using the command
python3-pipinstead (works on Fedora; I don't have a copy of Kubuntu to try it on).Just a wild guess...check
pip --version. There is a slight possibility that after installingpython3-pipthe newpipwould replace the oldpip(perhaps viaalternatives?)
EDIT
Now that the output of dpkg -L python3-pip has been added to the question, I can provide the answer.
The correct command name to use is: pip-3.2.
I ran into this problem and found the solution. The python3-pip package installed a pip-3.2 binary.
Executing pip-3.2 --version shows:
pip 1.1 from /usr/lib/python3/dist-packages (python 3.2)
Whereas python3-pip gives the command not found message.
I tested it on a "clean" download from here: https://sourceforge.net/projects/rpiqemuwindows/
I checked for pip-3.2 before installing python3-pip and then after.
Ubuntu 12.10+ and Fedora 13+ have a package called python3-pip which will install pip-3.2 (or pip-3.3, pip-3.4 or pip3 for newer versions) without needing this jumping through hoops.
I came across this and fixed this without needing the likes of wget or virtualenvs (assuming Ubuntu 12.04):
- Install package
python3-setuptools: runsudo aptitude install python3-setuptools, this will give you the commandeasy_install3. - Install pip using Python 3's setuptools: run
sudo easy_install3 pip, this will give you the commandpip-3.2like kev's solution. - Install your PyPI packages: run
sudo pip-3.2 install <package>(installing python packages into your base system requires root, of course). - …
- Profit!
You may want to build a virtualenv of python3, then install packages of python3 after activating the virtualenv. So your system won't be messed up :)
This could be something like:
Copyvirtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install package-name