0

I'm runnning a virtualenv in the django-web folder. The folder has a Scripts folder which contains the python file django-admin.py. I would like to run this python file as: python django-admin.py from C:\Users\name\django-web with the virtualenv activated. The python file isn't found unfortunatly:

python: can't open file 'django-admin.py': [Errno 2] No such file or directory

when I look for the pythonpath in my virtual env:

(django-web) C:\Users\name\django-web>python Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information. import sys; print(sys.path) ['', 'C:\Users\name\django-web\lib\site-packages\django-1.6.5-py3.4.egg' , 'C:\Python34\Lib', 'C:\Python34\DLLs', 'C:\Windows\system32\python34.zi p', 'C:\Users\name\django-web\DLLs', 'C:\Users\name\django-web\lib', 'C:\Users\name\django-web\Scripts', 'C:\Users\name\django-web', 'C:\ \Users\name\django-web\lib\site-packages']

The path 'C:\Users\name\django-web\Scripts' where the file is located is clearly in the python path.

Running the file as python Scripts\django-admin.py from C:\Users\name\django-web runs fine.

2
  • 1
    When you run a script like this, PYTHONPATH is irrelevant; PYTHONPATH is only used when importing inside a Python script or module, not when finding executables or scripts. You should indeed run the script with its full path, as you mention in the last line. Alternatively, you'd have to make sure your PATH environment variable includes C:\Users\name\django-web\Scripts, and then you should be able to simple run django-admin.py (without Scripts` or python ` prepended. Commented Jul 30, 2014 at 12:35
  • @Evert that should have been an answer. Commented Jul 30, 2014 at 12:43

1 Answer 1

1

First of all, PYTHONPATH helps Python to find required modules while importing. In your case it does not matter because you are trying to run the script, it is not an import seems like you are executing python django-admin.py in wrong directory. Also you have to run virtualenv's python binary instead of regular one (just need to activate virtualenv)

virtual env HOW TO

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.