Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (19.9k points)

Ok, I see plenty of these errors around. I have tried everything I know to do and have yet to figure this out.

I am working on a development server running python 2.5 and Django 1.3. Django 1.3 was installed using python install after unpacking the tar.gz download.

All works well, I seldom have the need to run but am trying to use the new staticfiles app and am running into problems.

python collectstatic

Traceback (most recent call last):

  File "", line 2, in <module>

    from import execute_manager

ImportError: No module named

Ok, so I have PATH issue.

From Django install I double check my site-packages directory.

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"


Ok, let's check out what I have, echo $PYTHON_PATH was empty, so I set it

export PYTHON_PATH=/usr/lib/python2.5/site-packages/django

Still no luck. Lets check what sys.path has to say

>>> import sys

>>> print sys.path

['', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/django', '/var/lib/python-support/python2.5']

path is there, I even created /usr/lib/python2.5/site-packages/django.pth with contents

cat /usr/lib/python2.5/site-packages/django.pth 


Anyone got an clues to what is going on here?

I found a symlink further up the path that was getting in the way, but no on to a new error.

python collectstatic

Traceback (most recent call last):

  File "", line 14, in <module>


  File "/usr/lib/python2.5/site-packages/django/core/management/", line 438, in execute_manager


  File "/usr/lib/python2.5/site-packages/django/core/management/", line 349, in execute


  File "/usr/lib/python2.5/site-packages/django/", line 12, in get_version

    from django.utils.version import get_svn_revision

ImportError: No module named utils.version

I also tried creating a new project to see if there were any issues there and get the same utils.version error.

Side node: Unode from #django helped me a bit, set up virtualenv on same machine and got past the errors so still not sure what is up with this actual install here, but it seems to not be in the django projects but in the django/python install.

1 Answer

0 votes
by (25.1k points)

If, like me, you are running your django in a virtualenv, and getting this error, look at your The first line should define the python executable used to run the script. This should be the path to your virtualenv's python, but it is something wrong like /usr/bin/python, which is not the same path and will use the global python environment (and packages will be missing). Just change the path into the path to the python executable in your virtualenv.

You can also replace your shebang line with #!/usr/bin/env python. This should use the proper python environment and interpreter provided that you activate your virtualenv first (I assume you know how to do this).

Browse Categories