[Fixed]-Python + Django + VirtualEnv + Windows


I know this question is old and maybe not actual anymore for author. But as far as it appears at Google’s top, I would leave the answer that helped me.

Basically the correct answer is posted for the similar question.

Strictly speaking the wrong Python installation is called when you execute django-admin.py --version. in order to check which Python you use in the case, type ftype Python.File in “command line”. If it’s not the virtualenv’s one, then you could reassociate the default Python:

ftype Python.File="E:\CODE\wamp\www\AMBIENTES\env\Scripts\python.exe" "%1" %*

Or unset the file association (from cmd.exe):

assoc .py=
ftype Python.File=

After you reassociate the .py extension program, you should specify full path to execute Python files:

E:\CODE\wamp\www\AMBIENTES\env\Scripts\python.exe E:\CODE\wamp\www\AMBIENTES\env\Scripts\django-admin.py --version

Or if you want, you could edit virtualenv’s activate.bat to put specific .py association, using assoc and ftype command line utils, mentioned above.


I believe your problem is that using python setup.py install with the Django source is installing Django in your primary site-packages/dist-packages path instead of that of your virtual environment.

Instead, use pip or easy_install:

$ pip install Django==1.2.7  --OR -- $ easy_install Django==1.2.7

If you can’t directly download from PyPi (corporate firewall, etc.) you can use the source you already have by modifying the command slightly:

$ pip install -f file:///E/CODE/wamp/www/AMBIENTES/ Django==1.2.7

(Converted Windows path may need some tweaking. I think that’s right, but it’s been awhile)

Leave a comment