-2

My python is installed in c:\python27 and my site-packages is located in C:\Python27\Lib\site-packages. The problem, that I couldn't understand, is why if I put a script called base-install.py in site-packages and call it using

C:\Users\max>python base-install.py
python: can't open file 'base-install.py': [Errno 2] No such file or directory

The second problem is that I have same issue with virtualenv. When I create it and activate it with Scripts\activate.bat, if I try to call, for example python django-admin.py(which is correctly installed in site-packages of virtenv) I have same issue:

(test2) D:\www\test2>python django-admin.py
python: can't open file 'django-admin.py': [Errno 2] No such file or directory

I am stuck with this since 2 hours and I can't get where I mess it up.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
Maksim
  • 215
  • 2
  • 12

2 Answers2

1

You are confusing the python module search path with the file system path.

When you type this:

C:\Users\max>python base-install.py

python = This works, because the python executable (python.exe) is in your file system path. The Python installer adds the location of python.exe to your global file system path.

base-install.py This file is not in any directory that is in your file system path, and it is not in the directory max from where you are running the command, which is why you are getting the error.

The second problem is a bit easier to solve. In Windows, scripts are added to a Scripts directory:

Simply do:

(test2) D:\www\test2>python Scripts\django-admin.py

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
1

If you want to execute that script from some other location you shoud do:

    python -m base-install

This way if base-install.py is either in site-packages or in any other directory added to PYTHONPATH it should work.

Bogdan
  • 8,017
  • 6
  • 48
  • 64