Conflict between Python’s `pip` and Perl’s `pip`

Category: Computers

I am a Python programmer on Windows. I also happen to have Perl installed.

Both Python and Perl have a utility named pip. When I type pip install PACKAGE, I am expecting to ask Python’s pip to install a PACKAGE.

On a new computer I have a roughly 50:50 chance of getting this instead:

PS C:\WINDOWS\system32> pip install xlrd

Unknown or unsupported command 'install'

Due to Perl’s pip being ahead of Python’s pip in my PATH environment variable.

Fix that by editing your PATH environment variable, so that the C:\Python27\Scripts entry ** comes before the perl\bin entry.

** or C:\tools\python2\Scripts, if you use chocolatey.

PS C:\WINDOWS\system32> pip install xlrd unicodecsv
Collecting xlrd
  Downloading xlrd-0.9.4.tar.gz (322kB)
    100% |################################| 323kB 178kB/s
Collecting unicodecsv
  Downloading unicodecsv-0.13.0.tar.gz
Installing collected packages: xlrd, unicodecsv
  Running setup.py install for xlrd
  Running setup.py install for unicodecsv
Successfully installed unicodecsv-0.13.0 xlrd-0.9.4
PS C:\WINDOWS\system32>

Much better.


Addendum: how to figure out which thing is being called

The PowerShell equivalent to the Unix which command is called get-command. If you type get-command pip, you will get a list of all the things Windows thinks pip might refer to.

PS C:\WINDOWS\system32> get-command pip
CommandType     Name         Definition
-----------     ----         ----------
Application     pip.exe      C:\tools\python\Scripts\pip.exe
Application     pip.bat      C:\strawberry\perl\bin\pip.bat
Application     pip          C:\strawberry\perl\bin\pip