ImportError: No module named django.core

Another error caused by wrong access rights.

After installing Django 1.2.1 (wget  -> untar  -> install) on Ubuntu 10.04 64bit, attempt to start django-admin.py results in:

Traceback (most recent call last):

File "/usr/local/bin/django-admin.py", line 2, in <module>

from django.core import management

ImportError: No module named django.core

Testing within python shell results with similar error message:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)

[GCC 4.4.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import django

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: No module named django

>>> quit()

A little bit of investigation:

$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/usr/lib/python2.6/dist-packages

Looking the sys.path:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)

[GCC 4.4.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> print sys.path

['', '/usr/lib/python2.6/dist-packages/django', '/usr/local/lib/python2.6/dist-packages/django/bin', '/usr/local/lib/python2.6/dist-packages/django', '~/webapps', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/pymodules/python2.6']

And locating django-admin.py:

$ locate django-admin.py

~/install/sources/Django-1.2.1/build/lib.linux-i686-2.6/django/bin/django-admin.py

~/install/sources/Django-1.2.1/build/scripts-2.6/django-admin.py

~/install/sources/Django-1.2.1/django/bin/django-admin.py

/usr/local/bin/django-admin.py

/usr/local/lib/python2.6/dist-packages/django/bin/django-admin.py

/usr/local/lib/python2.6/dist-packages/django/bin/django-admin.pyc

Made me try to update the PYTHONPATH with this:

export PYTHONPATH="/usr/lib/python2.6/dist-packages/django:$PYTHONPATH"

and this:

export PYTHONPATH="/usr/local/lib/python2.6/dist-packages/django:$PYTHONPATH"

Do I need to say that “it didn’t work”? :) Again, it was usage rights… As you can see above, original django-admin.py is located in /usr/local/lib/python2.6/dist-packages/django/bin. While installing Nginx, I’ve already fixed the /usr/local folder and now it was turn for /usr/local/lib:

sudo chmod 711 /usr/local/lib

And, finally, Django works without troubles. ;)

, , ,

5 Comments

’403 Forbidden’ page after Nginx install

So, you went down the road of optimizing your web server and the Nginx was your choice. I did the same.

Installing “by the book” but after “make install” (or, in my case “checkinstall” as nginx’ makefile does not have the option for uninstall), all I could see was “403 Forbidden”. After checking default’s site folder(s) for hours and even granting 777, I have found that the problem was in access rights of the /usr/local where noone could execute it’s contents. I’m still not sure if Nginx install made this or my Ubuntu 10.04 64bit was installed with those, but the following line “healed” the server:

$ sudo chmod 711 /usr/local

And, voila! The Nginx default welcome page was there. :)

, ,

No Comments