Problem using django-admin.py in a virtual environment

100 views
Skip to first unread message

DIEGO CENZANO PRADO

unread,
Apr 4, 2012, 5:01:02 AM4/4/12
to django...@googlegroups.com
I have install django with 'python setup.py install' in a virtual environment called 'django1.3'

I run it and receive the following error mesage:

(django1.3) C:\Documentos de Diego\Dropbox\Codigo\Django>django-admin.py

Traceback (most recent call last):

  File "C:\Environments\django1.3\Scripts\django-admin.py", line 2, in <module>

    from django.core import management

ImportError: No module named django.core

Can anybody help me, please?

Andre Terra

unread,
Apr 4, 2012, 7:31:58 AM4/4/12
to django...@googlegroups.com
When you type 'django-admin.py foo' in a command prompt, windows will use the system wide python install which is what is associated with the .py extension. In order to avoid this, you must call 'python django-admin.py foo'.

If you don't like having to type 'python' before calling a script, you can alter your virtualenv activate script so that window's file association for Python files gets changed when a new environment gets activated. This has the downside of not reverting the association when you close a prompt without properly deactivating (by typing 'deactivate'), but I still like it, so there's a how-to below.


In order to tell the virtualenv to use your virtual python install when calling file.py directly, you need to modify the activate.bat script and add the following line somewhere in the beginning (after @echo off):

FTYPE Python.File="C:\Environments\django1.3\Scripts\python.exe" "%1" %*

Then add a line to revert this association change in deactivate.bat (located in the same folder):

FTYPE Python.File="C:\Python27\python.exe" "%1" %*

I did my best to guess the paths, but you might have to adjust them appropriately.


Hope that helps!

Cheers,
AT


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/WKzPnfWfh9UJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

DIEGO CENZANO PRADO

unread,
Apr 4, 2012, 8:31:19 AM4/4/12
to django...@googlegroups.com
It worked. Thank you very much.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages