ImportError: failed to import settings (is there sys.path? Is there an import error in the settings file?): No module name

I am going to execute the "example" project on VPS CentOS 6 (with Plesk ) with python2.7 , mod_wsgi , Django 1.6 . I have proven many configurations, and I always get the error message “No modules with settings” or “Without a module named Unipath”. Not that I was wrong or lacking. Thank you and welcome.

My vhost.conf:

Alias /static/ /var/www/vhosts/example.com/httpdocs/ Alias /media/ /var/www/vhosts/example.com/httpdocs/media/ WSGIScriptAlias / /var/www/vhosts/example.com/example.wsgi <Directory /var/www/vhosts/example.com> Order allow,deny Allow from all </Directory> 

My example. wsgi:

 import os import sys path = '/var/www/vhosts/example.com/example' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() 

I placed my project via ftp in: /var/www/vhosts/example.com/

 example.com/ example(project) settings.py urls.py ... app models.py forms.py views.py ... templates httpdocs example.wsgi manage.py 

Thanks again...

+7
django mod-wsgi centos6 plesk
source share
3 answers

Read the official Django documentation on how to configure things for mod_wsgi:

You do not set the search path of the Python module or DJANGO_SETTINGS_MODULE as described in this document.

0
source share

Your settings are shown in an example application, so it should be:

 os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings' 
+2
source share

Use WSGIDaemonProcess and WSGIProcessGroup

You can solve this problem by setting the python-path configuration in apache2 to specify in the django project directory

 Alias /static/ /var/www/vhosts/example.com/httpdocs/ Alias /media/ /var/www/vhosts/example.com/httpdocs/media/ WSGIScriptAlias / /var/www/vhosts/example.com/example.wsgi WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP} python-path=/var/www/vhosts WSGIProcessGroup example.com <Directory /var/www/vhosts/example.com> Order allow,deny Allow from all </Directory> 
  • Edited to switch from Embedded mode to Daemon mode. Credit to Graham Dumpleton , who authored this blog post , he also commented.
0
source share

All Articles