python - 在 apache2/windows 上以 wsgi 模式执行的 python3 烧瓶应用程序的问题
问题描述
我有一个烧瓶应用程序,可以在使用 python 3.8 以独立模式(main.py)启动时工作。当我在 apache2/windows 上以模式 wsgi (main.wsgi) 启动它时,应用程序启动但在 apache2 日志中出现此错误并崩溃:
from mysql.connector import *
AttributeError: module 'mysql.connector' has no attribute 'CMySQLConnection'
什么可以解释两个相同代码之间的这种行为差异?
我的 Apache2 虚拟主机:
define ROOT "C:/Data/st-2020/dev/python/cours-2020/v01-deployment/flask"
define SITE "impots"
<VirtualHost *:80>
WSGIScriptAlias /app "${ROOT}/mainWithMySQL.wsgi"
DocumentRoot "${ROOT}"
ServerName ${SITE}
ServerAlias *.${SITE}
<Directory "${ROOT}">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我的 Apache2 httpd.conf:
# python wsgi
LoadFile "c:/myprograms/python38/python38.dll"
LoadModule wsgi_module "c:/myprograms/python38/lib/site-packages/mod_wsgi/server/mod_wsgi.cp38-win_amd64.pyd"
WSGIPythonHome "c:/myprograms/python38"
解决方案
问题是
from mysql.connector import *
我不得不将其重写为:
from mysql.connector import connect
我不知道为什么。
推荐阅读
- bash - BASH脚本按位置查找文件中的字符串,匹配,然后修改该位置并插入(如果存在)
- python - 将 Cython 编译为 32 位应用程序时出错
- php - PHP 错误 - 警告:count():参数必须是数组或实现 Countable 的对象
- python - ็如何通过python代码防止heroku休眠模式
- javascript - 如何在codeigniter中对数据表求和
- java - 如何获得输出和图形的第二部分?
- javascript - 单引号中的 Javascript 查询字符串
- java - 如何将 if else 语句中启动的值用于语句之外?
- r - 如何按组完成案例
- python - Python - 尝试从输入中减去时间(不支持的操作数类型)