0

I am on Parrot OS.

I have both python 2 and Python 3 installed.

┌─[✗]─[jaysmito@parrot]─[~/]
└──╼ $python --version
Python 3.9.2
┌─[jaysmito@parrot]─[~/]
└──╼ $python2 --version
Python 2.7.18

And pip:

┌─[✗]─[jaysmito@parrot]─[~/]
└──╼ $pip --version
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)
┌─[jaysmito@parrot]─[~/]
└──╼ $pip3 --version
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

I want to install a package for python2 but that is already installed for python 3

┌─[jaysmito@parrot]─[~/]
└──╼ $pip install xdg
Requirement already satisfied: xdg in /usr/lib/python3/dist-packages (5)
┌─[jaysmito@parrot]─[~/]
└──╼ $pip3 install xdg
Requirement already satisfied: xdg in /usr/lib/python3/dist-packages (5)
┌─[jaysmito@parrot]─[~/]
└──╼ $python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xdg
>>> exit()
┌─[jaysmito@parrot]─[~/]
└──╼ $python2
Python 2.7.18 (default, Mar  9 2021, 11:09:26) 
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xdg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named xdg

How can i solve this issue?

1
  • Does pip2 use the Python2 version of pip?
    – Mokubai
    Commented Apr 22, 2021 at 13:40

1 Answer 1

0

You only have pip for python3. To install it for python2, you need to either install it through a package manager or the install script from a url

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python2 get-pip.py

you should have pip installed for python2 now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .