我正在尝试使用mod_wsgi运行我的Flask应用程序,但是mod_wsgi会给出错误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'
mxnet包安装在python3.5中。所有软件包都安装在此文件夹中。
<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>
答案 0 :(得分:1)
变化:
WSGIScriptAlias /fdapp /var/www/FDApp/fdapp.wsgi
为:
WSGIScriptAlias /fdapp /var/www/FDApp/fdapp.wsgi \
process-group=fdapp application-group=%{GLOBAL}
您没有告诉mod_wsgi在守护程序进程组中运行您的应用程序。
另外,使用:
python-home=/home/teja/.local/lib/python3.5/site-packages
错了。
对于每位用户site-packages
,请使用:
python-path=/home/teja/.local/lib/python3.5/site-packages