16👍
I solved the problem by adding location of site-packages, where I have kept django subdirectory (/Library/python/2.7/site-packages) to WSGIDaemonProcess:
WSGIDaemonProcess www.example.com processes=2 threads=15 display-name=%{GROUP}
python-path=/Library/python/2.7/site-packages
If you are using embedded server mode use in httpd.conf
:
WSGIPythonPath /Library/python/2.7/site-packages
4👍
Why are you even trying to add the site-packages directory into sys.path? If your mod_wsgi is compiled against Python 2.4, then it should already be looking in the site-packages directory. Sounds like your mod_wsgi isn’t even compiled against Python 2.4.
Run:
ldd mod_wsgi.so
against your installed mod_wsgi.so file to work out what Python version it is compiled for and post the result.
- [Django]-How to get the current url namespace using Django?
- [Django]-Using IntellijIdea within an existing virtualenv
- [Django]-How can I apply a filter to a nested resource in Django REST framework?
3👍
I’ve had this issue before, and it was because the Apache/mod_wsgi process did not have permission to read the modules. You can make your site-packages/django directory world-readable, or add other appropriate user/group permissions.
- [Django]-What's the difference between CharField and TextField in Django?
- [Django]-Django: Add non_field_error from view?
- [Django]-Where are the Assertion Methods list from Django TestCase?
3👍
Wrong:
WSGIDaemonProcess www.example.com python-path=~/virtualenvs/virt1/lib/python2.7
Right:
WSGIDaemonProcess www.example.com python-path=/home/user/virtualenvs/virt1/lib/python2.7
I spent way too much time trying to figure out why my virtualenv wasn’t loading django properly.
- [Django]-Test Django views that require login using RequestFactory
- [Django]-Django testing rest-framework: APIRequestFactory vs APIClient
- [Django]-Django model field by variable
2👍
I solved this issue by adding the parent directory that holds my django installation to sys.path in wsgi.py. Here are my settings, FWIW:
/home/banjer/myproject/wsgi.py:
import os, sys
sys.path.append('/home/banjer/django')
sys.path.append('/home/banjer') # this line solved it
sys.executable = '/usr/local/python-2.7.2/bin/python'
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
- [Django]-In Django – Model Inheritance – Does it allow you to override a parent model's attribute?
- [Django]-How can I set a default value for a field in a Django model?
- [Django]-How can I store an array of strings in a Django model?
1👍
Check your site-package file permissions.
None of the above solutions worked for me until I fix file permissions.
Here’s what’s in my ssl_error_log file:
mod_wsgi (pid=986, process='OSQA', application='xxxxxx.yyy.com|/forum'): Loading WSGI script '/data/http/osqa/osqa.wsgi'.
mod_wsgi (pid=986): Target WSGI script '/data/http/osqa/osqa.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=986): Exception occurred processing WSGI script '/data/http/osqa/osqa.wsgi'. Traceback (most recent call last): File "/data/http/osqa/osqa.wsgi", line 14, in <module>
import django.core.handlers.wsgi ImportError: No module named django.core.handlers.wsgi
But I solved it on my server. If you can do this on the command line, then this solution is for you:
python
>>> import django.core.handlers.wsgi
>>>
What worked is that I chmod go+rx site-packages libpython*
(this might be overkill, but it worked for me.)
I’m running as httpd as apache.user, and running python as root, could see the packages just fine, but my permissions were not setup correctly (to read by everyone), and that’s why httpd could not read the packages.
- [Django]-UnicodeDecodeError : 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
- [Django]-What is the difference render() and redirect() in Django?
- [Django]-In django, how do I call the subcommand 'syncdb' from the initialization script?
0👍
This line is certainly wrong:
sys.path.append('/usr/lib/python2.4/site-packages/django')
Install Django with/for the version of Python that mod_wsgi was built against.
- [Django]-Get the index of an element in a queryset
- [Django]-How do I do a not equal in Django queryset filtering?
- [Django]-Django error message "Add a related_name argument to the definition"
0👍
I know this is a somewhat old question, but I thought I’d chime in for future SO users who might find this question:
Your mod_wsgi is linked to python2.6, yet you’re using python 2.4 to run django according to your config?
I’m going to assume your /usr/bin/python is pointing to something other than the 2.6 which is what mod_wsgi is compiled against. It might also be due to the fact that you’re running django against 2.4. I received the same error when I was loading mod_wsgi linked against python2.6 when django was using python2.7. With the version of mod_wsgi I have installed – it came with support for both python2.[6-7], so all I had to do was remove the symlink in /usr/lib/apache2/modules/ for mod_wsgi.so -> mod_wsgi.so-2.6 and change it to mod_wsgi.so -> mod_wsgi.so-2.7.
Easy enough.
- [Django]-Django – pisa : adding images to PDF output
- [Django]-Unable log in to the django admin page with a valid username and password
- [Django]-EmailBackend for sending email through multiple SMTP in Django
0👍
It would be a better idea if you remove django from your old python library..
[root@lts5srv1]# rm -rf /root/epd-5.1.0/lib/python2.5/site-packages/django
..and reinstall it inside the ‘site-packages’ folder of the current python you are using:
[root@lts5srv1 Django-1.4.1]# /usr/local/bin/python2.6 setup.py install
That’s what i did and i don’t get that error anymore!
- [Django]-PyCharm hangs on 'scanning files to index' background task
- [Django]-Django rest framework: query parameters in detail_route
- [Django]-Django 2.1.3 Error: __init__() takes 1 positional argument but 2 were given
0👍
Hello!
If you use deb-distributive of Linux (Debian, Ubuntu, etc), edit the file
/etc/apache2/modules/wsgi.load
This file contained path to correct wsgi-library (for active version Python interpreter). If you use Python2.6, change string
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so-2.7
to
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so-2.6
Also, you can change soft link to mod_wsgi module:
cd /usr/lib/apache2/modules
ln -s mod_wsgi.so-2.6 mod_wsgi.so
Not forget change link to file in /etc/apache2/modules/wsgi.load and restart apache server
service apache2 restart
P.S. Sorry for my bad English
- [Django]-Using JSON in django template
- [Django]-How do I modify the session in the Django test framework
- [Django]-Django 1.5 custom User model error. "Manager isn't available; User has been swapped"