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.
#1 by startproject on 3. June 2010 - 17:36
Thanks a lot for both this and the Nginx fix! It saved me a lot of trouble!
Don’t know why it happens, I was also installing default stuff…
#2 by PlanB on 3. June 2010 - 22:19
Hi,
You welcome; I’m also not sure yet why it happens, but it was pain to track it down – that’s for sure
#3 by Hernan on 23. September 2010 - 4:11
Hello
It happens the same problem but in windows 7 64bit’s. Could you help please?
#4 by PlanB on 15. October 2010 - 18:12
Obviously, the only reason this happens is that some resources cannot be accessed… Do you use 32 or 64 bit Python (I’d advise 32bit)?