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
I encountered this problem today, it turned out that I had C:\Python26 in my path and .py files were associated to Python 3.1. Repairing the proper version of Python, either through Programs and Features or by running the .msi, will fix the associations.
I had the same problem, it was clear that I had a
PYTHONPATH
configuration issue. The solution is quite simple, just create a file with this namedjango.pth
in yourPYTHONHOME\Lib\site-packages
directory wherePYTHONHOME
is the directory where Python is installed (mine is: C:\Python27). Add the following line to thedjango.pth
file:Of course you have to change
PYTHONHOME
to your Python's installation directory as I explained.Note that you can edit the
django.pth
to include any directory that you want to be included in thePYTHONPATH
. Actually, you can name that file as you wish,path.pth
for example if you want it to be more general and to include several directory paths.The simplest solution though not the most elegant is to copy the django-admin.py from the Scripts folder. The Scripts folder will be found under your Python installation . On my computer it is in C:\Python26\Scripts. Then paste the django-admin.py into the folder you are trying to run the file from. It is true that the use of the System path will give flexibility. This is a particular solution if you are in a hurry. Then type for instance python django-admin.py startproject fluffyteaspoons and you will create the project fluffyteaspoons
In my case, I'm on OS X Lion and I've installed Python with homebrew I was getting the same error, but none of the solutions posted here helped me. In my case I just had to edit the script:
And I noticed that the first line was wrong, as it was pointing to the system's python installation:
I just modified it to point to homebrew's installation:
And it worked :)
As usual, an install script failed to set world read/execute permissions :) Do this:
To tack on to what lichenbo said... If you are using Windows, then Don't run with 'django-admin.py'...
I'm running inside a virtual environment, so the path and command to create a new project looks like:
DjangoEnv is the name of my virtual environment.