Teja
Teja

Reputation: 967

mod_wsgi cannot load my Flask app

I am trying to run my Flask application with mod_wsgi, but mod_wsgi gives the error Target WSGI script '/var/www/FDApp/fdapp.wsgi' cannot be loaded as Python module.

mod_wsgi: Compiled for Python/3.5.1+.
mod_wsgi: Runtime using Python/3.5.2.
mod_wsgi (pid=4142): Target WSGI script '/var/www/FDApp/fdapp.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=4142): Exception occurred processing WSGI script '/var/www/FDApp/fdapp.wsgi'.
Traceback (most recent call last):
  File "/var/www/FDApp/fdapp.wsgi", line 6, in <module>
    from main import app as application
  File "/var/www/FDApp/main.py", line 15, in <module>
    import label_faces
  File "/var/www/FDApp/label_faces.py", line 2, in <module>
    import mxnet as mx
ImportError: No module named 'mxnet'

The mxnet package is installed in python3.5. All the packages are installed in this folder.

        <VirtualHost *:80>
                        ServerName 127.0.0.1
                        WSGIDaemonProcess fdapp user=www-data group=www-data threads=5  python-path=/home/teja/.local/lib/python3.5/site-packages
                        WSGIScriptAlias /fdapp /var/www/FDApp/fdapp.wsgi process-group=fdapp application-group=%{GLOBAL}
                        <Directory /var/www/FDApp/>
                                WSGIProcessGroup fdapp
                                WSGIApplicationGroup %{GLOBAL}
                                WSGIScriptReloading On
                                Order allow,deny
                                Allow from all
                        </Directory>

                        Alias /static1 /var/www/FDApp/static
                        <Directory /var/www/FDApp/static/>
                                Order allow,deny
                                Allow from all
                        </Directory>
                        ErrorLog ${APACHE_LOG_DIR}/error.log
                        LogLevel warn
                        CustomLog ${APACHE_LOG_DIR}/access.log combined
        </VirtualHost>

Upvotes: 1

Views: 1127

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

Change:

WSGIScriptAlias /fdapp /var/www/FDApp/fdapp.wsgi

to:

WSGIScriptAlias /fdapp /var/www/FDApp/fdapp.wsgi \
    process-group=fdapp application-group=%{GLOBAL}

You aren't telling mod_wsgi to run your application in the daemon process group.

Also, using:

python-home=/home/teja/.local/lib/python3.5/site-packages

is wrong.

For per user site-packages use:

python-path=/home/teja/.local/lib/python3.5/site-packages

Upvotes: 2

Related Questions