4

I have python 2.7.10 installed on windows and I am trying to install Django on the commandline with the following command:

C:/users/user/myproject> python pip install django

This displays the following error:

python: can't open file 'pip' [Errno 2] No such file or directory

Python is installed in C:\Python27 and the PATH environment variable is also set to that.

Why is pip not working?

Sebastian Wozny
  • 13,254
  • 4
  • 42
  • 60
Nant
  • 519
  • 2
  • 8
  • 21
  • 1
    you have to install pip first http://pip.readthedocs.org/en/stable/installing/ – Geo Jacob Nov 09 '15 at 12:02
  • 2
    you have to ensure that `C:\Python27\Scripts` is in your system environment variable `%PATH%` – Nhor Nov 09 '15 at 12:03
  • I have a similar issue in a conda environment under Windows. I would usually install a local packages with `pip install -e .`. The command works fine, I get the message ´successfully installed {package}´, though ´python -c "import {package}"´ does not find it then. – Sören Mar 11 '19 at 22:25

2 Answers2

10

Since Python 2.7.9 pip is included when python is installed.

However the scripts subfolder of your python installation might not be added to your PATH environment variable, and hence inaccessible by just typing pip install. However as long as your python executable is on the path, you can use the python -m flag to execute the pip module as a script:

python -m pip install SomePackage

This should work from the command line as long as python is on PATH.

If you would like to use pip directly from the cmd.exe prompt you need to add the scripts directory to your PATH environment variable:

SET PATH=%PATH%;C:\Python27\scripts
Sebastian Wozny
  • 13,254
  • 4
  • 42
  • 60
  • I was able to install packages. Could you please explain the use of -m as without using I got error only, and when used it successfully ran. – Gaurav Parek Nov 19 '17 at 13:23
0

Some times in windows it especially needs Microsoft visual c++ compiler. If such error persists you can verify the log file and If needed you can download here http://aka.ms/vcpython27

Pavan Nath
  • 1,494
  • 11
  • 21