My pip isn't working, for both versions of python

Viewed 571

so i have installed both python 2.7 and python 3.8 however in the cmd if i type one of these:

pip install

pip --version

it uses the python 2.7 version. I don't think that i can use the packages installed with python 3. i have tried:

  • Reinstalling python (2 & 3)

  • Adding it to my PATH

  • Changing the directory that it is saved in

  • Pip3 commands

  • bootstraping pip

yet none have worked.(also im on windows 7, and require the pip and python for both 2.7 & 3.8)

when i use:

python3 -m pip install x

or

py -3 -m pip install x

it comes up with:

DLL load failed while importing pyexpat: the specified module could not be found

3 Answers

Python 3 command in Windows is python3. So if you want to run pip with python 3 you have to do python3 -m pip install.

You can also replace Python 2 path in your Path variable to your Python 3 path, like so when you'll run python command it will use Python 3 directly.

Hope i got useful.

Have a look at the official document,

https://docs.python.org/3/installing/index.html?highlight=pip#work-with-multiple-versions-of-python-installed-in-parallel

if you are on windows you can use,

py -2   -m pip install SomePackage  # default Python 2
py -2.7 -m pip install SomePackage  # specifically Python 2.7
py -3   -m pip install SomePackage  # default Python 3
py -3.4 -m pip install SomePackage  # specifically Python 3.4

On Linux, Mac OS X, and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:

python2   -m pip install SomePackage  # default Python 2
python2.7 -m pip install SomePackage  # specifically Python 2.7
python3   -m pip install SomePackage  # default Python 3
python3.4 -m pip install SomePackage  # specifically Python 3.4

hope this helps!

If you install both versions of python then by simply entering pip command will run that python pip whose path comes first. You could use pip3 for pip corresponding to python3 and pip2 for pip corresponding to python2. But the recommended way is to do following:

For Python 3

py -3 -m pip install

For Python 2

py -2 -m pip install
Related