Меню

Sudo apt install python3 pip ошибка

I installed Ubuntu 20.04 on a PC. I then tried to get started and install pip for python3. However nothing seemed to work.
This is what I have tried so far:

sudo apt install python3-pip

This is the error I get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python3-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-pip' has no installation candidate

I have tried the solution proposed by Carlos Sanchez JR.:
How to install Python package installer PIP on Ubuntu 20.04 Linux

After following the advice given in the link above I got this error when doing sudo apt update :

Ign:1 cdrom://Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423) focal InRelease
Hit:2 cdrom://Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423) focal Release
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease              
Hit:6 http://archive.ubuntu.com/ubuntu focal InRelease                        
Get:5 http://kali.download/kali kali-rolling InRelease [30.5 kB]
Hit:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Err:5 http://kali.download/kali kali-rolling InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
Get:8 http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease [30.5 kB]
Err:8 http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
Reading package lists... Done
W: GPG error: http://kali.download/kali kali-rolling InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
E: The repository 'http://http.kali.org/kali kali-rolling InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ED444FF07D8D0BF6
E: The repository 'http://kali.cs.nctu.edu.tw/kali kali-rolling InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Trying sudo apt install python3-pip at this point just gives me the same E: Package 'python3-pip' has no installation candidate error as before. This is equally true when trying
sudo apt-get install python3-pip.

I have found no other solutions to this problem.

sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip

how to install python-pip in ubuntu:14.04?

Boyka's user avatar

Boyka

7992 gold badges8 silver badges16 bronze badges

asked Sep 11, 2015 at 7:01

R_SS's user avatar

2

python-pip is in the universe repositories, therefore use the steps below:

sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python-pip

answered Sep 11, 2015 at 8:19

A.B.'s user avatar

A.B.A.B.

87.6k21 gold badges242 silver badges317 bronze badges

20

I ran into this problem trying to install pip for python2; e.i. I wanted pip2. What worked for me was this:

sudo apt-get update && sudo apt-get install python-pip

Hope this helps someone.

anonymous2's user avatar

anonymous2

4,2286 gold badges31 silver badges61 bronze badges

answered Apr 5, 2017 at 19:00

Robbotnik's user avatar

RobbotnikRobbotnik

3012 silver badges3 bronze badges

1

Sometimes you get the error package python pip has no installation candidate in your Linux system. In this entire tutorial, you will know how to solve the error package python pip has no installation candidate in a very simple way.

Most of the time python pip has no installation candidate Comes when you are updating the version of python. Suppose my Linux system has a python 2. xx version and I want to update the python3 version. To do so I will use the below lines of command.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 20

The above command will install the python to the 3.8.20 version. You can check the current version of python using the below bash command.

sudo python3 --version

Checking the version of python in linux

Checking the version of python in Linux

But due to some corrupt modules of the python, you will get the package python-pip has no installation candidate error when you will try to install to the python3 pip module.

sudo apt install python3-pip

Output

E: Package 'python3-pip' has no installation candidate

Solution of the python pip has no installation candidate Error

Most of cases this type of error comes when you forget to update the Linux repository databases. To solve this error you have to follow the three steps.

Step 1: Enable the universe repository

The first step is to enable the universe repository. To do so you have to run the below command.

sudo add-apt-repository universe

Step 2: Synchronize package database

The next step is to update the package database so that you will easily install the latest modules provided by the Linux database.

sudo apt update

Step 3: Install the pip3 module

After all the steps the last step is to install the pip3 module. Run the below command to install it.

sudo apt install python3-pip

That’s all you have to do to remove the python-pip has no installation candidate error. Please note that when you try to install any package in Linux then first update the Linux packages and then install any module.

I hope you have liked this tutorial. If you have any queries then you can contact us for more help.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

We respect your privacy and take protecting it seriously

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Introduction

Pip is a python library, package manager that allows you to download and install packages from the (Python Package Index) PyPi repository. When you try to download a package using the pip without having a pip package manager, an error will raise on the terminal window ‘pip: command not found.

In this guide, We will show you the main causes of this error and how to fix the pip command not found error on the Ubuntu 20.04 system using a potential solution.

What is “pip command not found” error ?

The python-pip package manager works as an independent package manager on Linux distribution. This means you need to install the pip tool separately from python programs.

The pip command is not found an error raised on your Linux terminal window if the pip is not installed independently on Ubuntu 20.04 system. Therefore, before installing any package using pip, the pip tool should be installed on your Ubuntu system.

ALSO READ: Install Nodejs and NPM on Raspberry Pi [Step-by-Step]

When are working with the python3 version, you can use the pip or pip3 as well while installing a new python package on your system.
For example, you want to install a python package ‘scrapy’ using the pip command:

$ pip3 install scrapy

The following pip: command not found error displays on the terminal. This means pip is not installed on your Ubuntu system.

pip command not found

How to fix pip command not found error on Ubuntu 20.04?

There can be two versions of pip (at the time of writing article python4 was not released so once python4 is available, it is possible we have another version of pip) i.e. from python2 and python3.

So based on your requirement and environment you can choose to install the respective pip version (although python2 is mostly deprecated and you can choose to install pip from Python3).

Scenario-1: Install pip package manager for Python3

When pip command not found error is raised on your terminal window, you can easily fix the error by running the below-mentioned command:

$ sudo apt install python3-pip

The above command will install the pip package manager on your Ubuntu 20.04 system as follows:

install python3 pip

Display the pip installed version by using the following command:

$ pip --version
or
$ pip3 --version

[Solved] pip command not found Ubuntu 20.04

ALSO READ: Install Sublime Text 4 on AlmaLinux 8 [Step-by-Step]

Now, you can go ahead an install a package using pip package manager by running the following command:

$ pip3 install scrapy

As you will notice, the above command will not show any error. It directly installs the scrapy python module on your system Ubuntu 20.04.

install package using pip3

Scenario-2: Install pip package manager for Python2

Python 2 version has obsoleted now. This means Python 2 is no longer to use or maintained properly. Now, everyone moving towards the python 3 versions. So, try to move your python code over to the codebase that supports the newest Python 3 framework. But, if you still need to install the pip2 package manager tool then, download the get-pip.py script using the curl command as follows:

$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

get pip script

Now, you can install pip for the python2 version using the following command:

$ sudo python2 get-pip.py

install pip2 using script

Print the pip2 installed version using the below-mentioned command:

$ pip2 --version

pip2 version

How to use the pip command?

Using the pip command, you easily install packages from the python packages index repository, local projects, version control, and distribution files.
To get installation help related to python3 packages, use the following pip3command:

$ pip3 install --help

pip3 install help

List all pip3 packages or modules

To list all pip3 packages, use the following command:

$ pip3 list

pip3 packages list

ALSO READ: How to Install PowerISO on Linux [Step-by-Step]

Install and uninstall a package using pip

Now, you can install a package from the pip3 packages list.

$ pip3 install package-name

Similarly, you can also uninstall it via pip3 or pip command. To uninstall a package using pip3, run the below-given command:

$ pip3 uninstall package-name

[Solved] pip command not found Ubuntu 20.04

Upgrade a package using pip

You can also upgrade a specific package to its latest version using pip as follows:

$ pip install --upgrade package-name

Conclusion

We discussed two main reasons due to which the pip: command not found error raised. First, the pip is not installed on your Ubuntu system, or if two different python versions are installed on your system and you accidentally executed the pip command instead of pip3. Using the above-proposed solution I hope you can easily fix this error.

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

Перейти к содержанию

Главная » Linux » Исправление “E: Invalid operation python3-pip” в Kali Linux

Опубликовано 29.11.2021

Иногда во время установки python3-pip в Kali Linux, появляется ошибка «E: Invalid operation python3-pip» (Недопустимая операция python3-pip). В этой короткой замети мы расскажем вам как исправить эту проблему.

E: Invalid operation python3-pip

Invalid operation python3-pip

Invalid operation python3-pip

Устранение ошибки «E: Invalid operation python3-pip»

Чтобы решить (исправить) ошибку «E: Invalid operation python3-pip», требуется всего лишь выполнить несколько простых команд по порядку.

echo "deb http://http.kali.org/kali kali-rolling main non-free contrib" | sudo tee /etc/apt/sources.list


sudo apt-get install software-properties-common


sudo add-apt-repository ppa:deadsnakes/ppa


sudo apt-get update


sudo apt-get install python3-pip

apt-get install software-properties-common

apt-get install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
add-apt-repository ppa:deadsnakes/ppa
install python3-pip
install python3-pip

У вас должно получится тоже самое что и на скриншотах. Если есть замечания и предложения воспользуйтесь разделом комментарий.

The apt-get pip installation error “Unable to locate package python-pip” can occur if your apt repositories are out of date, or if your system uses python3-pip or python2-pip packages instead. You may already have it – check to see if the pip2 or pip3 commands are available.

The other day I was toying around with an older version of Ubuntu. Or, rather, I was stuck using an older version of Ubuntu for reasons I’d rather forget. When trying to install some Python package via pip install <whatever>, I got:

“Hmm, weird” I thought. I could have sworn it was already installed. But, I’ve been in this situation a million times before. I know exactly what to do!

Then I did the next logical thing, and tried running:

sudo apt-get install python-pip

But, unfortunately, that didn’t do what I thought it was going to do. Instead, I was greeted with the following error message:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip

What. That always used to work!

Fortunately, I was able to figure it out. Let’s look at a few different ways you can install pip – one of these will work!

Fix 1: You might already have it!

If you’re not able to run the pip command, it’s possible your system already has it installed as pip2 or pip3 instead. Newer versions of Debian based systems like Ubuntu 20.04 will install Python 2 as “python2” and Python 3 as “python3”. I really look forward to the day when this isn’t the case. Literally nobody should be using Python 2 anymore. It’s been long enough.

Anyway, try the following if you must use Python 2 and need pip as well:

pip2 install <your package>

Or, if you’re really trying to get pip for Python 3, try this:

pip3 install <your package>

Still didn’t work? Alright, well, moving on then…

Fix 2: Try installing python2-pip or python3-pip instead

The next logical step, if pip2 or pip3 didn’t work, is to try installing those. You can short-circuit the guesswork if you can figure out if you have the python2 or python3 commands. Depending on which version of Python you actually want, that is.

If you have one of those, good news! One of the following commands should work.

If you want Python 2 pip, run this:

sudo apt-get install python2-pip

And if you want Python 3 pip, try this one:

sudo apt-get install python3-pip

Still nothing?? Well, don’t worry. I have a few more tricks up my sleeve.

Fix 3: Update your apt repositories

You might just need to update your apt repositories. Unlikely, yes, but still possible. python2-pip or python3-pip should have already been in your apt packages list on install. But, maybe you installed your OS without internet access, or maybe you just… did something weird. I don’t know.

It’s worth a try though, right?

Try the following:

sudo apt-get update && sudo apt-get install python-pip

If that didn’t work, try substituting “python-pip” with one of the specific variations, python2-pip or python3-pip. Yes, we’re grasping at straws here.

Fix 4: Add the “universe” repository

If you made it this far wit no luck, we might be in trouble. But, hang in there. We have a couple more things to try.

You might have some success by installing the “universe” repository. Beware though, these are packages from all over the place, not just the Debian or Ubuntu sanctioned ones. We don’t need their rules anyway, right? Please don’t sue me if you break something – you’ve been warned!

sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python-pip

Again, if you don’t have success trying python-pip, try the python2-pip or python3-pip packages instead.

Fix 5: Use the ensurepip module

Python comes with a built-in way to make sure pip in installed. Though, it’s unlikely to work if you’re on Ubuntu or Debian, because they usually disable it. Or, at least, it’s always disabled when I try this. But it’s worth a shot. I’ve been saying that a lot lately… hopefully you haven’t had to read down this far.

python -m ensurepip --upgrade

You’re more than likely going to get the following error or some variation of it:

ensurepip is disabled in Debian/Ubuntu for the system python.
Python modules for the system python are usually handled by dpkg and apt-get.
    apt install python3-<module name>
Install the python3-pip package to use pip itself.  Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.

Rats. Now we’re down to our nuclear option – use the get-pip script.

Fix 6: Use the get-pip.py script

Alright – this is guaranteed to work, but it’s definitely not the best option. Why? Because on Debian and Ubuntu, packages like pip are managed through apt. And if you step outside that package management system, you’re asking for trouble, because now apt doesn’t know what you have installed, and you can’t uninstall or manage dependencies for those packages with apt.

But, if this is an emergency, go ahead and give it a try:

curl https://bootstrap.pypa.io/get-pip.py | python

Or, if you don’t have curl installed and can’t or don’t want to install it, you can use wget instead with the following one-liner:

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

There you go. Now you should have pip.

You might get the following warning:

WARNING: The scripts pip, pip3 and pip3.9 are installed in '/home/user/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

If you do, that means you’ll have to add /home/<you>/.local/bin to your $PATH environment variable. You can do this (if you use bash) by adding the following to the bottom of your .bashrc file:

You’ll have to log out / log back in again for this to take effect. Or open a new terminal window if you’re logged into the desktop environment.

Conclusion

So there you go, one of those was guaranteed to work. Well, I can’t say “guaranteed”, because there’s always something, but I can say “probably”. Yeah, we’ll go with that. One of those probably worked. If you can think of any possible solutions I may have missed please let me know!

Hope this helped, and if it didn’t, good luck.

Are you looking for ways to fix «pip: command not found» error message?
Pip, short for Preferred Installer Program, is a package management program written in Python and for Python. It can manage local packages, install/update them from Python Package Index (PyPI) and remove them at will. Users can also use pip to fetch packages from other package repositories as well, provided that they’re compatible with PEP 503.

Installing pip is easy, and should be easy, but still, there are common problems that happens to people from time to time, one of them is the annoying «pip: command not found» message, even though you’ve just installed pip.

This article is going to explain why «pip: command not found» sometimes pops up and provide a few possible fix to the error message.

The error message simply indicates that the system cannot find pip’s executable in places that it supposed to be.

The first thing you need to check is whether pip directory is included in PATH environment variable. Most operating systems look for executables and binaries in a specific set of places. The list of all those places is stored in an environment variable, often named PATH.

Another thing that can cause the problem is that the installed version of pip’s binary may not be named pip, hence, invalidate the command.

If you haven’t been able to identify the problem, the simplest way to fix is to reinstall pip. Please note that most of the time, reinstalling pip won’t cause any problem because all its code is contained in a single binary file, and the pip command simply call that binary. Having two identical executable binary in the same system won’t ever be a problem at all.

Reinstall pip using package managers

Python is open-source and popular, therefore, it’s no surprise that almost every major operating system include it in their standard distributions, or provide easy ways to install it.
In Debian/Ubuntu and its derivatives, you can run

sudo apt install python3-pip

In CentOS, RHEL and other distribution based on them, you have to add EPEL repository before actually install pip

yum install epel-release
yum install python-pip

Arch Linux uses pacman instead of apt and yum, so the command to install pip should be

pacman -S python-pip

On a Fedora system, one can install pip with the following command

dnf install python3-pip

Mac users have to run a brew command to get pip sorted out along with Python

brew install python

Most of the time, running one of the above command alone will fix the problem right away. You can verify it’s a successful installation with the command below.

pip --version

Reinstall pip using get-pip.py

Reinstall pip using get-pip.py

If installing pip using package managers doesn’t work for you, try using get-pip.py, the official way to install pip, as per pip’s official documentation page.

get-pip.py is a bootstrapping script that enables users to install pip, setuptools, and wheel in Python environments that don’t already have them.

Let’s suppose you’re using Linux and already have wget installed on your system, you can run the following command to install pip. Please remember that in a few specific installation, you have to replace python with python3 to execute the right Python version.

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

Reinstall pip using ensurepip

Recent versions of Python, specifically from Python 3.4, are bundled with a new ensurepip module as part of the standard packages. The ensurepip provides support for bootstrapping the pip installer into an existing Python installation or virtual environment.

ensurepip bootstrapping approach reflects the fact that pip is an independent project with its own release cycle, and the latest available stable version is bundled with maintenance and feature releases of the CPython reference interpreter.

You can simply run the following command to get pip installed. Please remember that in a few specific installation, you have to replace python with python3 to execute the right Python version.

python -m ensurepip

More information on ensurepip can be found at ensurepip — Bootstrapping the pip installer.

Double-check PATH environment variables

There are also a chance that pip path is not included in PATH environment variables. Most of the time, pip should be placed in /usr/local/bin in Linux and $HOME/homebrew/bin in MacOS.

You should add the following line to ~/.bash_profile to add /usr/local/bin to PATH every time the system starts and see if the problem goes away.

export PATH="/usr/local/bin:$PATH"

On MacOS, replace /usr/local/bin with $HOME/homebrew/bin so it would look like this:

export PATH="$HOME/homebrew/bin:$PATH"

Once you’re done the editing, restart the computer.

Add pip as an alias for pip3

A common scenario is that the installed pip executable is named pip3. Python 3 is not backwards-compatible, which means that programs that are written in Python 2 won’t run in Python 3 and vice versa. In order to keep the standard legacy applications, in specific versions, OSes keeps both Python 2 and Python 3. In that case, pip for Python 2 will be executed with pip and the one for Python3 is named pip3.

Run the following command to see if pip3 is actually installed.

pip3 --version

The system should response back a message indicates the pip version along with the Python version.

[email protected]:~$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Now you have two options. You can use pip3 as it is or you can change the alias so that pip actually call pip3 executable. If you prefer the latter, run this command

alias pip=pip3

You would have to add the line above to ~/.bashrc or ~/.zprofile (in case you use ZSH) if you want the alias to persist through restarts.

Conclusion

We hope that the solutions above works for your case. If it didn’t, there may be something seriously wrong with your install, your best bet would be to reinstall the whole operating system from scratch or use another pip alternative such as conda.

You may like our other guides for Python to fix common error messages in Python, including «[Errno 32] Broken pipe» in Python, How to fix locale.Error: unsupported locale setting in Python or How to fix “unindent does not match any outer indentation level” indentation error in Python.

I have just installed Ubuntu 20.04 and I have come across an issue when trying to install pip. On my older machines running 18.04, the command ran fine and installed the package. However, when installing it on 20.04, I am getting this issue:

toffee@theia:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-pip

I have the universe repo added, I have done countless reboots, updates and upgrades. Is there any way I can fix this?

asked Apr 24, 2020 at 16:06

Toffee's user avatar

I don’t believe python-pip exists anymore in 20.04, looks like it has been removed from the repositories and is removed during the upgrade from 18.04(in my case 19.10) to 20.04. Maybe the functionality of the package has been bundled with a different python package?

20.04 upgrade

answered Apr 24, 2020 at 18:09

Matthew Swanson's user avatar

1

Use pip3 instead of pip

I will assume you are using the Python3 version so you can install pip3 with

sudo apt-get install python3-pip

then you can install whatever you wanted starting with;

pip3 install

All the best 🙂

answered May 23, 2020 at 10:31

Bill's user avatar

1

First of all try to search package

apt-cache search pip | grep python

Then

dpkg -l | grep python

to see if python is installed
Finally try

python3 -m pip 

answered Apr 24, 2020 at 16:39

geoai777's user avatar

2

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Sudo apt install openssh server ошибка
  • Substring not found python ошибка