I am using centos linux.
I had python 2.6 with django and now i upgraded to python 2.7.
Python 2.6 is located in /usr/lib/python2.6.
Python 2.7 is located in /usr/local/lib/python2.7.
They both have site-packages directory and they both contain django 1.2.
If i run python i get the 2.7 version.
My problem is that if try to import django i get
ImportError: No module named django
I am not sure where is my PYTHONPATH defined and if this is what i need to change. anyone ?
i ended up making a symbolic link to the 2.6 site-packages directory.
Under linux, you can set the PYTHONPATH environment variable in your .profile or .bashrc. You can either edit it directly from the terminal by changing to your home directory (cd ~), and then edit the file (nano .bashrc), or by opening the file with gtkedit or vim or whatever, and add:
If you want to test this before editing your profile, you can export this from the terminal as:
I'm assuming you're running this straight from the command line. If you're running it as a wsgi module in apache, you can add this to your syspath from your wsgi file as:
try
this command show which packages are installed in your system then run with root privilege
then create a new project with command
then start your project
in file wsgi.py add this lines
To check your path, you can use the following code:
If you already know where django is installed, it should be easy to test if the desired directory is in your path with
directory in sys.path
.Regarding where your
PYTHONPATH
is defined, note that it's an environment variable, so you can check its value (if defined) with:echo $PYTHONPATH
I had the same error, and this fix my issue
python -m pip install django
:) Done!
Try printing
sys.path
to see what's in your path. Django need to be in one of the dirs listed. Example on Windows: