Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting this error

File "/usr/local/lib/python2.7/site-packages/django/utils/", line 35, in import_module

TemplateSyntaxError: Caught ImportError while rendering: No module named django_bcrypt.

django_bcrypt is installed and can be imported at python shell.

django_bcrypt is installed at /root/src/django_bcrypt

Also I have an old python 2.4 /usr/bin/python2.4

And my new one is /usr/local/bin/python2.7

I also have one /usr/local/bin/python

I checked the sys.path,sys.prefix,sys.version using a wsgi script.Everything is correct.

First i was having an error import site failed error.I corrected it by adding WSGIPythonHome /usr/local

share|improve this question

Do you have your Python path set? By default, /root/src won't be in your PYTHONPATH, so you'll either need to install it into your site packages (recommended!), or add this path to your PYTHONPATH variable. See the mod_wsgi documentation for how to do this.

share|improve this answer
Apache/mod_wsgi will never see your PYTHONPATH variable. Append directory to sys.path in WSGI script file instead. – Graham Dumpleton Dec 29 '11 at 21:54
I tried that,still same error.Help please. – Jibin Dec 30 '11 at 5:18
Have you made sure that user that Apache runs your code as can even read the directory the module is in as well as all the code files. If you have restrictive permissions on directory it will not be able to access them. The /root directory may even be owned by root with no access to anyone else and so no way Apache user can read it. – Graham Dumpleton Dec 30 '11 at 11:22
Graham, could it also be possible that he compiled mod_wsgi against a different version of Python than the one he's trying to run the script with? – Andrew M. Dec 31 '11 at 1:44
Possibly, but his initial error of import site failed is consistent with what will happen when it is built properly against a Python in non standard location. That is, it will see /usr/bin/python and think therefore that Python 2.7 is under /usr when it isn't and so they had to use WSGIPythonHome so that it knew 2.7 was actually under /usr/local. If it was built against different Python version under /usr, wouldn't have expected it to get the import site failed message. So, on face value doesn't look like that sort of conflict. – Graham Dumpleton Dec 31 '11 at 6:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.