Problems running VirtualEnv under Windows.




After reading 'Practical Django Projects' I decided that I want to
implement the VirtualEnv tip suggested in order to properly segregate
code/modules in different projects. I am however having problems with
my django installations not using site-packages within the virtualenv
but rather attempting to use site-packages in the default python
installation directory.

Recreating the problem:

1) Install Python 2.7 via the Windows installer. Add C:/Python27;C:/
Python27/Scripts to Windows PATH.
2) Install setuptools-0.6c11-py2.7.egg via the Windows installer.
3) Install VirtualEnv through `pip install virtualenv`
4) Create an VirtualEnv via `virtualenv --no-site-packages MyEnvName`
5) Activate VirtualEnv via `../MyEnvName/Scripts/activate.bat`
6) Install django via `pip install django`
7) Run startproject ProjectName
8) Error results stating django.core module does not exist.

NB: This error will not occur if django is installed in your root
NB2: Running the Python interpreter in active VirtualEnv to print the
sys.path shows the correct paths. Which has just futher added to my

I'd appreciate any insight or troubleshooting assistance.






I've resolved this issue by deleting the *.py file association in

You can do this either by associating *.py with something like
textpad, using a utility such as or
doing so in the registry.

Note that when using the command like you need to issue commands with
a preceding `python` keyword.

For example in a normal installation enviroment the following is
possible ` startproject MyProject`, however in a
VirtualEnv with *.py associations removed one must do `python django- startproject MyProject` otherwise Windows will attempt to
open the file in the default application even if there isn't one.



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question