Configuring django using virtualenv on windows7

I was unable to start a new project in virtualenv. This is what I have done so far: (installing fresh windows)

1) installed python 2.7 from http://python.org/download/ (and not 64)

2) using "set path =% path%; C: \ python27" seems to work only for one cmd session, so I added C: \ Python27; in my environment variables under advanced system settings, python input in cmd returns

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 

3) downloaded virtualenv.py from http://pypi.python.org/pypi/virtualenv/, launched it using

 C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS>python virtualenv.py testenv New python executable in testenv\Scripts\python.exe Installing setuptools....................................done. Installing pip.........................done. 

4) activated it and installed some modules

 C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts>activate (testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts> ... (testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS>pip install -r requirements.txt ... Successfully installed... 

5) if it works:

 testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> print(django.get_version()) 1.4 >>> 

6) I tried to install the project:

 (testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>django-admin.py startproject testproject Traceback (most recent call last): File "C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts\django-admin.py" , line 2, in <module> from django.core import management ImportError: No module named django.core 

Path from virtualenv:

 (testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['','C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages\\pip-1.1-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\DLLs', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\plat-win', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\lib-tk', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\Scripts', 'C:\\Python27\\Lib', 'C:\\Python27\\DLLs', 'C:\\Python27\\Lib\\lib-tk', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv', 'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages'] 

I have no idea what the problem is, and how to fix it, another question also arises: should these files from c: \ python27 be in my virtual path? Should I attach any other magazines? Knock me if yes.

+4
source share
4 answers

Step 6 is where everything starts to go wrong.

Your windows have associated .py (w) files for using Python from the c: \ python27 directory, and not from your virtualenv.

I wrote a blog entry about virtualenv and win7: http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

+3
source

I agree with jtiai, in step 6, everything went wrong because Windows bound specific Python. If you did python path/to/django-admin.py startproject , it should work.

+2
source

Instead of using virtualenv on Windows, I prefer to use Portable Python: http://www.portablepython.com/ . You can have multiple installations on the same machine and switch between them just by setting the path:

 set path=d:\python\app\scripts;d:\python\app;%path% 

In addition, it already contains Django. After setting up the python environment, you can copy the python directory to your production server.

-2
source

All Articles