2
votes

I do have Win7 64 bit. Sequence of my action is below

  1. I have installed python 2.7.3. system path is clear.
  2. Then i did install virtualenv and pip
  3. Next is sequence of mine command

    • cd c:\Users\developer\
    • mkdir .virtualenv
    • cd .virtualenv
    • virtualenv --distribute --no-site-packages djangos
    • cd djangos
    • cd script
    • activate.bat
    • pip install django

now i include into system path env a directory

c:\Users\developer\.virtualenv\django\scripts

here is the problem. if type in console

cd c:\Project

django-admin.py startproject helloworld

then i am getting

Traceback (most recent call last):
  File "C:\Users\developer\.virtualenv\djangos\Scripts\django-admin.py", line 2, in     <module>
    from django.core import management
ImportError: No module named django.core

but if i do run
python
and the inside interpreter

>>import django
>>django.VERSION
>>(1, 4, 0, 'final', 0)
>>from django import core
>>from django.core import managment

I dont receive any error

only way to create project it is to run
(djangos) c:\Projects>python c:\Users\developer.virtualenv\djangos\Scripts\django-admin.py startproject hello

if there is a way to avoid every time to type full path in cli?

3
activete.bat ? shouldn't it be activate.batPierre Lacave

3 Answers

1
votes

Instead of

django-admin.py startproject helloworld

Try

python django-admin.py startproject helloworld

It worked for me.

1
votes

The problem is that Windows make automatic files associations for .py files to a specific python.exe executable. Even if you activate a virtualenv, errors will be raised when trying to execute the command:

django-admin.py

The reason is that the python.exe used to execute the script is still the one associated with .py files by Windows. In my case, the default Windows association is C:\Python27\python.exe. This is despite having configured and activated the virtualenv to point to C:\Users\developer.virtenv\django\scripts\python.exe.

To correctly execute djano-admin.py, either use a full path like:

C:\users\developer\.virtenv\django\scripts\python.exe django-admin.py

Or, delete the default Windows association to .py files. That way, when virtualenv is activated, it will amend the %PATH% variable to point to the python.exe in the virtual environment.

~~~

(Note: This problem doesn't generally occur on Linux machines. It's particular to the way Windows works.)

0
votes

It seems to me your activation of the virtualenv failed. Thus Django was installed in site-packages which you specifically excluded. Try to create a virtualenv without --no-site-packages to test if this is the case.

You can always create an alias or symlink to shortcut commands, try google