0

ubuntu@ip-172-31-18-233:my_folder$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

I installed pip using:

sudo apt install python-pip

The python version:

python --version
Python 3.6.9

But, when I try to install any package, I am getting this error.

sudo pip install yamlpath
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main

sudo pip3 install yamlpath
sudo: pip3: command not found

 python -m pip install yamlpath
/usr/bin/python: No module named pip
uday
  • 352
  • 10
  • 30

3 Answers3

1

#Below version is for python 2 only

sudo apt remove python-pip -y

#Python3 version of pip

sudo apt install -y python3-pip

#Setting as default version

sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
uday
  • 352
  • 10
  • 30
0

You might take a look at this stackoverflow question.

In short, you've got two pips that aren't playing nicely together. If you uninstall one, you might be able to manage with the other. There are too many viable solutions in the answers to justify writing them out here. Maybe just sudo apt-get remove pip3 and trying to find your existing pip. Personally, I'd cycle through these:

pip --version
pip3 --version
python3 -m pip --version
python3 -m pip3 --version

For example, I have 20.0.2 for pip3 --version and python3 -m pip --version

This should help you find your version once the conflicting install is removed.

cschl
  • 1
  • pip3 doesn't exist at all, you can see the output I shared earlier: pip3:command not found – uday May 26 '21 at 05:20
  • My mistake. Then you could try to remove the regular pip. The central theme here is that you've got two competing installs. They probably aren't pip and pip3, but both pips. – cschl May 26 '21 at 12:02
  • When I ran the pip command first, I got error as pip command not found. So, installed it using sudo apt install python-pip. Then, I am getting this error. – uday May 27 '21 at 06:49
0

To resolve these issues, I recommend trying the following steps:

Upgrade pip:

python -m ensurepip --upgrade

Try installing yamlpath using python -m pip:

python -m pip install yamlpath

If you still encounter errors, please provide more information about your system and the exact error message you receive, so I can help you better.