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

1 Answer 1

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.

5
  • 1
    Apache/mod_wsgi will never see your PYTHONPATH variable. Append directory to sys.path in WSGI script file instead. Commented Dec 29, 2011 at 21:54
  • I tried that,still same error.Help please. Commented Dec 30, 2011 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. Commented Dec 30, 2011 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? Commented Dec 31, 2011 at 1: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. Commented Dec 31, 2011 at 6:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.