apache - 目标 WSGI 脚本无法作为 python 模块加载,并使用 python 2.7 而不是 venv 中的 python 版本编译
问题描述
Wsgi 无法使用 venv 中的 python 版本编译应用程序,而是始终使用 python 2.7 编译。这是我的文件,请帮忙
我正在尝试使用 Apache 2.4.6 和 mod-wsgi 部署烧瓶应用程序 centos 7。
目标 WSGI 脚本 '/home/nmapi/project/dir/app.wsgi' 无法加载,因为 Python 模块是错误
这是我的 app.wsgi
activate_this = '/home/nmapi/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
使用您的应用程序路径展开 Python 类路径
from werkzeug.wsgi import DispatcherMiddleware
import sys
import logging
print(sys.path)
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"home/nmapi/project/dir")
from run import *
我的虚拟主机配置是
WSGISocketPrefix /var/run/wsgi
#ServerName sample.server.com
WSGIApplicationGroup %{GLOBAL}
WSGIDaemonProcess score threads=5 python-home=/home/nmapi:home/nmapi/deps/venv/lib/python3.5
WSGIScriptAlias /test_wsgi
/home/nmapi/project/dir/datascience.wsgi
<Directory /home/nmapi/project/dir/>
#WSGIProcessGroup score
#AllowOverride All
Require all granted
#Allow from all
</Directory>
Alias /static /home/nmapi/project/dir/static
<Directory /home/nmapi/project/dir/static/>
WSGIProcessGroup score
#WSGIApplicationGroup %{GLOBAL}
#AllowOverride All
Require all granted
#Allow from all
</Directory>
ErrorLog logs/error.log
#ErrorLog /tmp/error.log
LogLevel debug
#CustomLog /tmp/access.log combined
CustomLog logs/access.log combined
解决方案
推荐阅读
- c++ - 如何在 WINDOWS 中使用 C/C++ 在 UDP 套接字中设置超时?
- c++ - 通过将两个 for 循环合二为一来简化代码
- android - Android Kotlin:我的按钮内的倒数计时器
- javascript - 根据滑块索引位置更改类名
- c# - 没有通用基类的通用访问属性
- python - 拆分以删除多个值
- javascript - React Redux 错误 - 在“Connect(Form(SignUpForm))”的上下文中找不到存储
- firebase - 在 Flutter 中从 Firebase 实时数据库中获取特定数据
- google-apps-script - 用于合并列并在另一列中自动更新的谷歌工作表脚本
- apache-kafka - KeyValueStore Kafka 中 range() 方法的用途是什么?