3

I've seen many threads about this, and have tried all options except for completely wiping Python off of my machine and re-downloading everything...

I'm using a Windows 10, 64-bit machine, and had already downloaded Python2.7. Commands like 'C:\>pip install seaborn' were not an issue.

I recently downloaded Python3.6, and now my pip will not work - it returns the error in the title.

I have added C:\Python27, C:\Python36, C:\Python27\Scripts, C:\Python36\Scripts to my Path, and still it won't work.

If I type in the command C:\>python27 -m pip install seaborn, however, the pip works. I am really confused why I can no longer just type in pip install and have it work.

Thanks in advance!

Xantium
  • 11,201
  • 10
  • 62
  • 89
Atlas King
  • 51
  • 1
  • 1
  • 7

4 Answers4

4

You have two versions of Python added to path. To differentiate between 2.7 and 3.6 you have to tell it which version you want otherwise each pip conflicts with the other (it does not know what to install and where) in other words you type pip you could either mean for Python 2 or for Python 3.

Do not rename pip it will break your system (you should not need to rename). Instead use those already provided..

Your system should have these already:

pip is universal. Best for one installation.

pip3 for Python 3. Best to distinguish between Python 2 and 3

pip3.6 to distinguish between different Python 3 installations.

The same goes for Python 2 installation.

pip, pip2 and pip2.7.

You need to use either pip3 (or pip2) or pip3.6 (or pip2.7) to install in future. This will allow the different versions to be recognised:

For Python 2:

pip2 install seaborn

For Python 3:

pip3 install seaborn

You should also now use shebang lines as well now (if you are not already) to distinguish between versions.

Xantium
  • 11,201
  • 10
  • 62
  • 89
  • Why are you copying my answer mate? I am gonna flag it – iam.Carrot Mar 01 '18 at 20:23
  • @iam.Carrot I am putting that back in. You method involves renaming. I think otherwise. My solution is different to yours. – Xantium Mar 01 '18 at 20:38
  • 1
    yeah now it's taken in a different direction. I'll retract the flag. Thanks for the effort on your part. I really appreciate it – iam.Carrot Mar 01 '18 at 20:47
  • 1
    @iam.Carrot Sorry about that I was not copying (and I am pleased that that you told me that it looked similar otherwise I would not have changed it). I am too vague often. I am very sorry for the confusion I caused. :( – Xantium Mar 01 '18 at 20:50
2

the issue is the ambiguity between the two pip that you've mentioned in the Environments. As you mentioned the issue only started occurring when you installed python3 on the same system where python2 was installed and both have pip and hence when you fire up pip in your cmd, Windows System isn't able to pick one out of the two.

Why does your C:>python27 -m pip install seaborn work? Well it's quite simple, since you've mentioned the python27 there, windows knows exactly which pip you're talking about.



How to fix it?

see the edits for this section. (I tried this, it didn't work) Removed it from the final answer to avoid confusion.


Alternatively, what you can do is,

rename your python.exe for python 3 to python3. Don't forget to put it inside your PATH environment. Just use python for python 2, python3 for python 3. Their pip are separated, pip for python 2. pip3 for python 3.

Now, run and see the below commands behave:

# will return the default version of pip
pip --version
# will use the Python 2 version of pip
pip2 --version
# will use the Python 3 version of pip
pip3 --version
iam.Carrot
  • 4,976
  • 2
  • 24
  • 71
  • 1
    I tried that as well. I renamed each pip.exe as pip27 and pip36, respectively. When I enter 'C:\pip27 install ', I still get the original error. – Atlas King Mar 01 '18 at 20:25
  • 1
    @AtlasKing did you restart your `cmd` after changing the environment settings and the file names? – iam.Carrot Mar 01 '18 at 20:26
  • @iam.Carrot I closed out of the window, yes. Additional info - I have 3 different pip files for both Python2 and Python 3. They are as follows: pip pip2 pip2.7 Python3 has similar names for its pip files. Why are there 3? I didn't download/delete anything that the default Python download incurred...Could there be a problem there? – Atlas King Mar 01 '18 at 20:29
  • @AtlasKing I've updated the answer can you please try now? – iam.Carrot Mar 01 '18 at 20:42
  • @Simon I think I may have goofed up...I tried renaming my original 'pip', the universal .exe :( even now when I call pip, pip2, or pip3, it still gives me the original error. Should I uninstall Python3 and redownload? – Atlas King Mar 01 '18 at 21:10
  • @AtlasKing Have you renamed everything to what is was before. Once you have run `pip3` and it should work. – Xantium Mar 01 '18 at 21:15
  • @AtlasKing If it still does not work remove one of them from path (2.7) and just test `pip` see if the error goes if it does not you might have to. If it does add it back to path and try what I suggested below. – Xantium Mar 01 '18 at 21:17
  • @Simon I renamed everything to its original/default setting. Still no luck. I also tried removing everything but Python27 and Python27\Scripts from my Path. Also no luck... – Atlas King Mar 01 '18 at 21:27
  • 1
    @AtlasKing uninstall `python 3` try the `pip` if it works then great. re-install `python 3` in a different directory. Set the environment variables and then fire the 3 commands that I've mentioned `pip --version`, ``pip2 --version` and `pip3 --version` in your cmd – iam.Carrot Mar 01 '18 at 21:30
2

Okay so I finally worked it out...

I uninstalled Python3.6 and deleted all relevant folders.

I then went to Control Panel>Programs>Progams and Features and repaired my Python2.7 program. pip works now (I think it got messed up since I tried to rename the universal pip.exe file -> don't do that!!).

After re-downloading Python3.6, I put my universal pip.exe download from Python3 in a different directory so the Path would not get it confused. I now have Paths for both pip2 and pip3 and all is okay.

Thanks for your help!

Atlas King
  • 51
  • 1
  • 1
  • 7
0

This is how I solved this issue on my end: (short answer, remove this folder C:\Python27)

Problem: I installed python 3, after uninstalling python 2.7. The issue here is that pip remains behind even after you uninstall python 2.7.

Solution: 1. Uninstall python 3 (if you have it installed). 2. Just in case, I would uninstall python 2.7. 3. This is the key: go to C:\Python27 ... and delete the entire directory (which also contains pip).

This solution is good for those that are fine with ONLY running Python 3 on their machines (which was my case).

megaqa
  • 1