[Fixed]-Why is virtualenvwrapper not adding my environment location to my $PATH

1👍

You don’t need to run python django-admin.py (in fact you shouldn’t), just run django-admin.py. python isn’t searching your $PATH; it’s going to look for the file in the current directory. So long as django-admin.py has its execute bit set, you can use it as a command without explicitly running python.

It also installs itself as django-admin, so you can make the command line a little cleaner:

django-admin startproject mysite

You don’t need the .py extension.

The underlying reason is that virtualenv modifies $PATH, which is what your shell (bash or whatever) uses to locate the command to execute. When you run python foo.py, the command is python, and $PATH is searched for that. foo.py is just a command argument, and your shell doesn’t look for that at all. When python runs, it looks for foo.py in the current directory (and also accepts a relative path like ../otherdir/foo.py or an absolute path like /home/someone/foo.py); it doesn’t care about $PATH at all.

Leave a comment