0

I am getting this error

File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", 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

Kenny Rasschaert
  • 9,045
  • 3
  • 42
  • 58
Jibin
  • 111
  • 1
  • 4

1 Answers1

1

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.

Andrew M.
  • 11,182
  • 2
  • 35
  • 29
  • 1
    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 05: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 01:44
  • 1
    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 06:19