【发布时间】:2018-08-21 01:27:06
【问题描述】:
我正在尝试在 Apache 服务器上运行 Python Web 应用程序。我已经安装了 mod_wsgi:
sudo apt-get install libapache2-mod-wsgi.
这是我的网站配置文件:
<virtualhost *:80>
ServerName 192.168.60.144
WSGIDaemonProcess myapp.dev processes=1 threads=1 python-home="/home/user/.pyenv/versions/3.6.1" python-path="/home/user/API" home='/home/user/API'
WSGIProcessGroup myapp.dev
WSGIScriptAlias / /home/user/API/config_files/myservice.wsgi.py
<Directory /home/user/API>
Order allow,deny
Allow from all
</Directory>
DocumentRoot /home/user/API/myservice/testdir
<Directory />
AllowOverride None
Require all granted
</Directory>
</virtualhost>
但是,在尝试访问网络应用程序时,我收到“内部服务器错误”。这是日志中的错误:
[2018 年 3 月 12 日星期一 13:34:04.054636] [wsgi:error] [pid 6762:tid 139768980616960] [remote 10.10.30.13:34438] mod_wsgi (pid=6762): Target WSGI script '/home/user/ API/config_files/myservice.wsgi.py' 不能作为 Python 模块加载。 [2018 年 3 月 12 日星期一 13:34:04.054665] [wsgi:error] [pid 6762:tid 139768980616960] [remote 10.10.30.13:34438] mod_wsgi (pid=6762): 处理 WSGI 脚本'/home/user/API 时发生异常/config_files/myservice.wsgi.py'。 [2018 年 3 月 12 日星期一 13:34:04.054693] [wsgi:error] [pid 6762:tid 139768980616960] [远程 10.10.30.13:34438] 回溯(最近一次通话最后): [2018 年 3 月 12 日星期一 13:34:04.054717] [wsgi:error] [pid 6762:tid 139768980616960] [远程 10.10.30.13:34438] 文件“/home/user/API/config_files/myservice.wsgi.py”,行6、在 [2018 年 3 月 12 日星期一 13:34:04.054752] [wsgi:error] [pid 6762:tid 139768980616960] [远程 10.10.30.13:34438] 来自 pathlib 导入路径 [2018 年 3 月 12 日星期一 13:34:04.054775] [wsgi:error] [pid 6762:tid 139768980616960] [远程 10.10.30.13:34438] ImportError: 没有名为 pathlib 的模块
我检查了 pyenv python 安装,它安装了 pathlib 模块。这意味着可能没有使用正确版本的 Python。如何检查正在使用的 Python 版本?我是否错误地设置了python-home 属性?
【问题讨论】:
标签: python apache mod-wsgi pyenv