I have updated to latest Django version 1.0.2 after uninstalling my old Django version.But now when I run django-admin.py I get the following error. How can I resolve this?
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\bin\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
It was a PYTHONPATH environment variable issue for me, as others mentioned above, but noone has really shown how to set it for people that could use the extra instruction.
Linux (bash)
I set this variable in my bashrc file in my home folder (.bashrc is the file for me since my shell is /bin/bash).
The path should be wherever your django source is. Mine is located at /usr/local/python-2.7.2/lib/python2.7/site-packages/django, so I just specified /usr/local/python-2.7.2/lib/python2.7/site-packages without the django portion.
OSX
On OSX the path is
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
and you can add it to/etc/profile
:After reading a lot I found a solution that works for me.
I have
Set all system variable in "path".No duplicate copy in user variable nor in the PYTHONPATH .
Then set Value in regedit
made a virtualenv in desired folder by command
virtualenv VENV
And finally in cmd
used command
at the root folder of the "VENV"
And It worked
I have the same problem on Windows and it seems I've found the problem. I have both 2.7 and 3.x installed. It seems it has something to do with the associate program of .py:
In commandline type:
and the result is:
.py=Python.File
which means .py is associated with Python.File
then I tried this:
I got:
Python.File="C:\Python32\python.exe" "%1" %*
which means in commandline .py is associated with my Python 3.2 installation -- and that's why I can't just type "django-admin.py blah blah" to use django.
ALL you need to do is change the association:
then everythong's okay!
This happened to me because I ran
pip
assudo
while my virtualenv is setup to not import outside site packages so Django was installed for the root user but not in the virtualenv, even though I had virtualenv activated when I ran sudo.Solution switch to root, activate venv then do pip install.
Well.. I do something radical. I unistall python and I delete from Environment
Variables/PATH this: ;C:\Python26\Scripts;C:\Python26.
And Its work... I had your problem before.This worked on Mac OS X
In the terminal run python In python: import sys print sys.path
Look for the site packages path. I found this in the output of sys.path: '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages'
exit python. Find where your current site-packages are. Mine were at /Library/Python/2.6/site-packages
Now be careful: Check the content of site-packages to be sure it is empty. That is, directory /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages should be empty, or just contain a readme file. If it is, delete that directory, because you are now about to make a symlink.
ln -s /Library/Python/2.6/site-packages /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
If you don't delete the folder you will put the symlink in the folder.
Other options are to add the path to the sys.path. I elected the symlink route because I have a couple of versions of python, I don't want several versions of Django, and just wanted to point to the known working copy.