I get the following error when running my website on apache2/ubuntu:
ModuleNotFoundError: No module named 'FlaskApp'
[Sun Jan 24 23:04:52.381039 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] mod_wsgi (pid=25239): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381091 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] mod_wsgi (pid=25239): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381163 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] Traceback (most recent call last):, referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381180 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: https://www.publimundo.cl/
[Sun Jan 24 23:04:52.381185 2021] [wsgi:error] [pid 25239] [client 190.160.166.19:49593] from FlaskApp import app as application, referer: https://www.publimundo.cl/
This is my virtual host configuration:
<VirtualHost *:443>
ServerAdmin admin#publimundo.cl
ServerName www.publimundo.cl
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLProtocol all -SSLv2 -SSLv3
Timeout 300
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 20
ErrorLog /var/log/site_logs/publimundo-error.log
CustomLog /var/log/site_logs/publimundo-access.log combined
<Directory "/var/www/FlaskApp">
AllowOverride All
Allow from All
Require all granted
Options +FollowSymLinks
</Directory>
Alias /static /var/www/FlaskApp/publimundo/static
<Directory "/var/www/FlaskApp/publimundo/static">
AllowOverride All
Allow from All
Require all granted
Options +FollowSymLinks
</Directory>
#Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/publimundo.cl/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/publimundo.cl/privkey.pem
</VirtualHost>
Also the content of flaskapp.wsgi is:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
from FlaskApp import app as application
application.secret_key = 'some secret key here'
what can be the root of the problem? I have tried many answers on stackoverflow but did not help.
Found my error. The flaskapp.wsgi should be as follows:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
from publimundo import app as application
application.secret_key = 'some secret key here'
Related
I am trying to deploy a Django application using apache and i am getting the following error
[Fri Oct 08 07:55:44.393237 2021] [wsgi:error] [pid 12424:tid 140450959271680] mod_wsgi (pid=12424): Target WSGI script '/home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py' cannot be loaded as Python module.
[Fri Oct 08 07:55:44.393281 2021] [wsgi:error] [pid 12424:tid 140450959271680] mod_wsgi (pid=12424): Exception occurred processing WSGI script '/home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py'.
[Fri Oct 08 07:55:44.393408 2021] [wsgi:error] [pid 12424:tid 140450959271680] Traceback (most recent call last):
[Fri Oct 08 07:55:44.393430 2021] [wsgi:error] [pid 12424:tid 140450959271680] File "/home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py", line 12, in <module>
[Fri Oct 08 07:55:44.393435 2021] [wsgi:error] [pid 12424:tid 140450959271680] from django.core.wsgi import get_wsgi_application
[Fri Oct 08 07:55:44.393446 2021] [wsgi:error] [pid 12424:tid 140450959271680] ModuleNotFoundError: No module named 'django'
My apache virtual host
<VirtualHost *:80>
DocumentRoot /home/preinstall/hx_preinstaller
ErrorLog ${APACHE_LOG_DIR}/preinstall_error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/preinstall/hx_preinstaller/hx_preinstaller>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/preinstall/hx_preinstaller>
Require all granted
</Directory>
WSGIDaemonProcess preinstall python-path=/home/preinstall/hx_preinstaller:/home/preinstall/.local/lib/python3.6/site-packages
WSGIProcessGroup preinstall
WSGIPassAuthorization On
WSGIScriptAlias / /home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py
</VirtualHost>
What should i do?..
Maybe its a python version mismatch , or you didnt add correctly the python path to the appache.conf .
go check this post to know more about this error ->>> link
I have configured Django 2.1.15 on Centos 7 with Apache 2.4.6-93., mod_wsgi, Virtualenv and Postgres.
And here is my apache conf file:
<VirtualHost *:80>
DocumentRoot /var/www/
Alias /static /var/www/myapp/static
<Directory /var/www/myapp/static>
Options FollowSymLinks
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog /var/www/myapp/logs/apis_error.log
CustomLog /var/www/myapp/logs/apis_access.log combined
LogLevel info
WSGIPassAuthorization On
WSGIDaemonProcess myapp python-path=/var/www/myapp:/var/www/myapp/venv/lib/python3.6/site-packages
WSGIProcessGroup myapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/www/myapp/myapp/wsgi.py
<Directory /var/www/myapp/myapp/myapp>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
The Apache log error:
[wsgi:error] [pid 4829] mod_wsgi (pid=4829, process='myapp', application=''): Loading WSGI script '/var/www/myapp/myapp/wsgi.py'.
[wsgi:error] [pid 4829] mod_wsgi (pid=4829): Target WSGI script '/var/www/myapp/myapp/wsgi.py' cannot be loaded as Python module.
[wsgi:error] [pid 4829] mod_wsgi (pid=4829): Exception occurred processing WSGI script '/var/www/myapp/myapp/wsgi.py'.
[wsgi:error] [pid 4829] Traceback (most recent call last):
[wsgi:error] [pid 4829] File "/var/www/myapp/myapp/wsgi.py", line 12, in <module>
[wsgi:error] [pid 4829] from django.core.wsgi import get_wsgi_application
[wsgi:error] [pid 4829] ModuleNotFoundError: No module named 'django.core'
[wsgi:info] [pid 4829] mod_wsgi (pid=4829, process='myapp', application=''): Loading WSGI script '/var/www/myapp/myapp/wsgi.py'.
[wsgi:error] [pid 4829] mod_wsgi (pid=4829): Target WSGI script '/var/www/myapp/myapp/wsgi.py' cannot be loaded as Python module.
[wsgi:error] [pid 4829] mod_wsgi (pid=4829): Exception occurred processing WSGI script '/var/www/myapp/myapp/wsgi.py'.
[wsgi:error] [pid 4829] Traceback (most recent call last):
[wsgi:error] [pid 4829] File "/var/www/myapp/myapp/wsgi.py", line 12, in <module>
[wsgi:error] [pid 4829] from django.core.wsgi import get_wsgi_application
[wsgi:error] [pid 4829] ModuleNotFoundError: No module named 'django.core'
Any idea what might be going on here?
Thanks!
i think you need to make some changes to vhost conf like
<VirtualHost *:80>
ServerName myapp.local # HERE: "ServerName" is missing
DocumentRoot /var/www/myapp # HERE: point to the root folder of your app
Alias /static /var/www/myapp/static
<Directory /var/www/myapp/static>
# Options FollowSymLinks
# Order allow,deny
# Allow from all
Require all granted
</Directory>
WSGIPassAuthorization On
WSGIDaemonProcess myapp python-path=/var/www/myapp:/var/www/myapp/venv/lib/python3.6/site-packages
WSGIProcessGroup myapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /var/www/myapp/myapp/wsgi.py
<Directory /var/www/myapp/myapp> # HERE: give the right location of "wsgi.py"
<Files wsgi.py>
Require all granted
</Files>
</Directory>
LogLevel info
ErrorLog /var/www/myapp/logs/apis_error.log
CustomLog /var/www/myapp/logs/apis_access.log combined
</VirtualHost>
let me know if this works for you.
I created a django project under /home/toto/Desktop named dash_test and I wanted to serve my Django application with Apache2 and mod_wsgi.
I installed the Apache web server, the mod_wsgi, and pip using this command sudo apt-get install python-pip apache2 libapache2-mod-wsgi. And I created a python virtual environment within the project directory named developer.
The allowed_hosts in the settings.py looks like this :
ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx', 'localhost', '127.0.0.1']`
I added the static_url and the static_root:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
I did run a collectstatic
And I configured apache by editing the 000-default.conf :
<VirtualHost *:80>
Alias /static /home/toto/Desktop/dash_test/static
<Directory /home/toto/Desktop/dash_test/static>
Require all granted
</Directory>
<Directory /home/toto/Desktop/dash_test/dash_test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess dash_test python-home=/home/toto/Desktop/dash_test/developer python-path=/home/toto/Desktop/dash_test
WSGIProcessGroup dash_test
WSGIScriptAlias / /home/toto/Desktop/dash_test/dash_test/wsgi.py
</VirtualHost>
when I try to access the localhost I get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80
Here is the content of the apache2 error.log:
[Thu Jun 14 13:25:48.134132 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] mod_wsgi (pid=21611): Target WSGI script '/home/toto/Desktop/dash_test/dash_test/wsgi.py' cannot be loaded as Python module.
[Thu Jun 14 13:25:48.134152 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] mod_wsgi (pid=21611): Exception occurred processing WSGI script '/home/toto/Desktop/dash_test/dash_test/wsgi.py'.
[Thu Jun 14 13:25:48.134167 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] Traceback (most recent call last):
[Thu Jun 14 13:25:48.134182 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] File "/home/toto/Desktop/dash_test/dash_test/wsgi.py", line 11, in <module>
[Thu Jun 14 13:25:48.134203 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] from django.core.wsgi import get_wsgi_application
[Thu Jun 14 13:25:48.134216 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] ImportError: No module named django.core.wsgi
I am using MySQL and phpMyAdmin instead of db.sqlite3
Thanks a lot.
Instead of:
<Directory /home/toto/Desktop/dash_test/dash_test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
use:
<Directory /home/toto/Desktop/dash_test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
You were using the wrong directory.
That or you have:
WSGIScriptAlias / /home/toto/Desktop/dash_test/wsgi.py
wrong and it is meant to be:
WSGIScriptAlias / /home/toto/Desktop/dash_test/dash_test/wsgi.py
The location of the wsgi.py doesn't actually look quite right if this is a Django app.
What is the actual path to the wsgi.py file.
The directory argument above should be the directory it is in.
I use Django 3.x and Apache 2.4 for upload my project in local host,indeed I going to test my project and Apache but I faced with same problem and when I check my Apache error.log it was : "ModuleNotFoundError: No module named 'django'"
And config file seems ok and when I check it with :"sudo apache2ctl configtest"
But I use this 2 commands for solve the problem
sudo a2dissite 000-default
sudo a2ensite 000-default
and
sudo systemctl reload apache2
I have developed Flask-Web-App which runs fine if I use python command-line directly. However, when I deployed to Apache2 with mod-wsgi it can't import its internal modules. I have read all the relevant posts similar to mine but couldn't figure out the issue yet. Firstly, I tried all below:
1 - Made sure all files and sub-folder under the application folder have rwx permission for www-data ("the Apache2 service account").
2 - Added the module path to the Apache config file using: WSGIPythonPath /var/www/FlaskApp/FlaskApp/Base/:/var/www/FlaskApp/FlaskApp/Base/Form/:/var/www/FlaskApp/FlaskApp/Base/Model/ (see below:)
3 - Added the module path to sys.path variable in wsgi script.
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
sys.path.append('/var/www/FlaskApp/FlaskApp/Base/')
sys.path.append('/var/www/FlaskApp/FlaskApp/Base/Form/')
sys.path.append('/var/www/FlaskApp/FlaskApp/Base/Model/')
from FlaskApp import app as application
application.secret_key = 'as345kj34h5kljj34sy'
All my internal imports are in init.py which starts up the application like below:
# internal imports
import Base.Model as Model
from Base import Constant as cnst
from Base.Form import UserRegistrationForm, ProductForm
.
.
.
if __name__ == "__main__":
app.run()
I just don't have any other idea what else I might have possibly missed. Again everything works just fine when using the python interpreter from command-line.
You help is MUCH MUCH appreciate it.
Regards,
Mehdi/Mike
Error.log
[Fri Sep 09 22:59:43.068802 2016] [mpm_event:notice] [pid 10719:tid 139878768617344] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Fri Sep 09 22:59:43.068872 2016] [core:notice] [pid 10719:tid 139878768617344] AH00094: Command line: '/usr/sbin/apache2'
[Fri Sep 09 22:59:47.926252 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] mod_wsgi (pid=10720): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module.
[Fri Sep 09 22:59:47.926300 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] mod_wsgi (pid=10720): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
[Fri Sep 09 22:59:47.926325 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] Traceback (most recent call last):
[Fri Sep 09 22:59:47.926343 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] File "/var/www/FlaskApp/flaskapp.wsgi", line 10, in <module>
[Fri Sep 09 22:59:47.926403 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] from FlaskApp import app as application
[Fri Sep 09 22:59:47.926414 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 22, in <module>
[Fri Sep 09 22:59:47.926848 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] from Base.Form import UserRegistrationForm, ProductForm
[Fri Sep 09 22:59:47.926889 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] File "/var/www/FlaskApp/FlaskApp/Base/Form/__init__.py", line 1, in <module>
[Fri Sep 09 22:59:47.926975 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] from UserRegistrationForm import UserRegistrationForm
[Fri Sep 09 22:59:47.927007 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] File "/var/www/FlaskApp/FlaskApp/Base/Form/UserRegistrationForm.py", line 2, in <module>
[Fri Sep 09 22:59:47.927098 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] from Base.Model import db_session, User
[Fri Sep 09 22:59:47.927156 2016] [:error] [pid 10720:tid 139878671300352] [client ::1:55866] ImportError: No module named Base.Model
flaskapp.wsgi
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
sys.path.append('/var/www/FlaskApp/FlaskApp/Base/')
sys.path.append('/var/www/FlaskApp/FlaskApp/Base/Form/')
sys.path.append('/var/www/FlaskApp/FlaskApp/Base/Model/')
from FlaskApp import app as application
application.secret_key = 'as345kj34h5kljj34sy'
FlaskApp.conf
WSGIPythonPath /var/www/FlaskApp/FlaskApp/Base/:/var/www/FlaskApp/FlaskApp/Base/Form/:/var/www/FlaskApp/FlaskApp/Base/Model/
<VirtualHost *:80>
ServerName localhost
ServerAdmin admin#eynaksara.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Instead of:
WSGIPythonPath /var/www/FlaskApp/FlaskApp/Base/:/var/www/FlaskApp/FlaskApp/Base/Form/:/var/www/FlaskApp/FlaskApp/Base/Model/
<VirtualHost *:80>
ServerName localhost
ServerAdmin admin#eynaksara.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
try using:
<VirtualHost *:80>
ServerName localhost
ServerAdmin admin#eynaksara.com
WSGIDaemonProcess myapp python-path=/var/www/FlaskApp/FlaskApp
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi process-group=myapp application-group=%{GLOBAL}
<Directory /var/www/FlaskApp>
<Files flaskapp.wsgi>
Order allow,deny
Allow from all
</Files>
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Changes made are:
Use mod_wsgi daemon mode not embedded mode. See http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html
Correct Apache directory access authorisation. That it worked as you had it suggests you have lax security settings elsewhere in Apache configuration as what you had shouldn't have worked. Have changed it to preferred mechanism, but you should work out why your Apache configuration has it allowing Apache to serve up any file in the file system.
Set the correct Python module search path. Done on the daemon process group since switched to that.
For use of Python main (application) interpreter context in daemon process group to avoid issues with third party extension modules for Python that will not work in sub interpreters.
I have seen plenty of previous messages related to my problem, but no answer could get rid of my "500 Server internal Error" so I try to post my conf to get help.
Error Message:
[Fri Jun 24 17:05:23.631270 2016] [authz_core:error] [pid 15187:tid 140715758237440] [client 127.0.0.1:47873] AH01630: client denied by server configuration: /home/www/waves/
[Fri Jun 24 17:05:23.631568 2016] [:error] [pid 15186:tid 140715648984832] ['/home/marc/.virtualenvs/waves/lib/python2.7/site-packages', '/home/www/waves', '/usr/local/lib/python2.7/dist-packages/setuptools-20.6.7-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
[Fri Jun 24 17:05:23.631660 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] mod_wsgi (pid=15186): Target WSGI script '/home/www/waves/waves_services/wsgi.py' cannot be loaded as Python module.
[Fri Jun 24 17:05:23.631675 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] mod_wsgi (pid=15186): Exception occurred processing WSGI script '/home/www/waves/waves_services/wsgi.py'.
[Fri Jun 24 17:05:23.631686 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] Traceback (most recent call last):
[Fri Jun 24 17:05:23.631710 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] File "/home/www/waves/waves_services/wsgi.py", line 18, in
[Fri Jun 24 17:05:23.631731 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] from django.core.wsgi import get_wsgi_application
[Fri Jun 24 17:05:23.631743 2016] [:error] [pid 15186:tid 140715648984832] [remote 127.0.0.1:50665] ImportError: No module named django.core.wsgi
My django app do not load in apache wsgi mode, I tried many solutions but still don't work. Here is my confs files :
Virtual host :
<VirtualHost *:80>
ServerName dev.www.waves.com
ServerAlias www.waves.com
ServerAdmin webmaster#waves.com
DocumentRoot /home/www/waves
Alias media/ /home/www/waves/media/
Alias static/ /home/www/waves/static/
<Directory /home/www/waves>
Require all granted
</Directory>
<Directory /home/www/waves/staticfiles>
Require all granted
</Directory>
<Directory /home/www/waves/media>
Require all granted
</Directory>
WSGIDaemonProcess waves python-path=/home/marc/.virtualenvs/waves/lib/python2.7/site-packages:/home/www/waves
WSGIProcessGroup waves
WSGIScriptAlias /waves /home/www/waves/waves_services/wsgi.py
<Directory /home/www/waves/waves_services>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/marc/.virtualenvs/waves/lib/python2.7/>
Require all granted
</Directory>
My wsgy.py content :
from __future__ import unicode_literals
import os
import sys
import site
print sys.path
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "waves_services.settings.production")
application = get_wsgi_application()
I traced to sys.path content in apache error log, and the virtualenv in in sys.path.
Django is installed in this virtualenv (I had first tried to install django 'globally' but the error was just moved to the first 'application specific' import : environ contained in my settings file.
The virtual env was created with virtualenvwrapper (any impact ?)
I tried as well to change ownership of virtualenv file, changed 'execution' flag as well, but still I get this ... 500 Server Error.
I would be grateful to get a clue of what is happening !
thanxs
Several things to check for.
Make sure that the virtualenv has django (pip freeze | grep django)
Check if apache user can access the virtualenv by checking the folder permissions
if you are using apache 2.4 + change the following
Order deny,allow
Allow from all
to
Require all granted
Edit suggested by #marcoooo (OP) : don't put virtualenv base dir under any home dir which do not have 'x' flag, apache www-data user won't be able to activate the virtualenv either.... Many thanxs to e4c5 for his help, and saved my day (and nights)