Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 2.7: cannot pip on windows "bash: pip: command not found"

I am trying to install the SciPy stack located at https://scipy.org/stackspec.html [I am only allowed 2 links; trying to use them wisely]. I realize that there are much easier ways to do this, but I think there is a lot to be learned by doing it manually. I am relatively new to a lot of this stuff, so I apologize if I sound ignorant at any point.

I am running Windows 7 Enterprise - 64 bit. Here is what I have done so far:

  1. Installed python-2.7.8.msi (32-bit) from https://www.python.org/download/releases/2.7.8/

  2. Installed numpy-1.8.1-win32-superpack-python2.7 from http://sourceforge.net/projects/numpy/files/
    Test: import numpy as np ---> no errors

  3. Installed scipy library,
    scipy-0.14.0-win32-superpack-python2.7.exe from (SCIPY DOT ORG LINK REMOVED) Test: import scipy as sp ---> no errors

  4. Installed matplotlib: matplotlib-1.3.1.win32-py2.7.exe from (MATPLOTLIB DOT ORG LINK REMOVED)

  5. Installed PIP by running script here: https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py I just copied-pasted script to a new file in IDLE,
    saved as C:\Python27\Scripts\pip_install.py and clicked Run>module. No errors reported.

Does the path on which I saved pip_install.py matter?


HERE IS WHERE I FAIL

Attempted to install matlibplot dependency dateutil: Opened a Cygwin Shell, and typed

        cd C:\Python27          ! is it necessary to cd to python directtory?
        pip install python-dateutil

This results in the error:

    bash: pip: command not found

I get the same error attempting from cmd.

Any help is appreciated; the closest I found was bash: pip: command not found. But the OSX nature of it is just enough to confise me further.


UPDATE:

I added the pip-path per Paul H's suggestion below. It made the error go away, but strangely, nothing I pip actually installs. For example, in Cygwin, I type:

cbennett2> pip install python-dateutil
cbennett2>                            

You can see that there is no output or feedback from the shell (which I think there should be). Then when I go to a new python shell:

>>> from dateutil.parser import parse
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    from dateutil.parser import parse
ImportError: No module named dateutil.parser
>>>>

This happens with all of the modules that I thought I had pip'd ... pandas, tornado, etc.

like image 387
Saladsamurai Avatar asked Aug 15 '14 14:08

Saladsamurai


People also ask

Does Python 2.7 have pip?

Python 2.7 must be having pip pre-installed. Try installing your package by: Open cmd as admin.

Why is pip not found?

'pip' is not recognized as an internal or external command, operable program or batch file. Linux – If you have installed Python on a Linux environment, the pip does not come with Python, and you need to install pip package manager as a separate package.


3 Answers

On Windows, pip lives in C:\[pythondir]\scripts.

So you'll need to add that to your system path in order to run it from the command prompt. You could alternatively cd into that directory each time, but that's a hassle.

See the top answer here for info on how to do that: Adding Python Path on Windows 7

Also, that is a terrifying way to install pip. Grab it from Christophe Gohlke. Grab everything else from there for that matter. http://www.lfd.uci.edu/~gohlke/pythonlibs/

like image 135
Paul H Avatar answered Oct 09 '22 16:10

Paul H


As long as pip lives within the scripts folder you can run

python -m pip ....

This will tell python to get pip from inside the scripts folder. This is also a good way to have both python2.7 and pyhton3.5 on you computer and have them in different locations. I currently have both python2 and pyhton3 installed on windows. When I type python it defaults to python2. But if I type python3 I can use python3. (I also had to change the python.exe file for python3 to "python3.exe")If I need to install flask for python 2 I can run

python -m pip install flask

and it will be installed in the pyhton2 folder, but if I need flask for python 3 I run:

python3 -m pip install flask

and I now have it in the python3 folder

like image 33
Buzz Avatar answered Oct 09 '22 15:10

Buzz


  1. press [win] + Pause
  2. Advanced settings
  3. System variables
  4. Append ;C:\python27\Scripts to the end of Path variable
  5. Restart console
like image 12
Ivan Temchenko Avatar answered Oct 09 '22 14:10

Ivan Temchenko