[英]Mysql not working with python 3.6 and django 1.9
我正在尝试使用django 1.9连接mysql db,而python版本是3.6。 使用数据库连接字符串时,出现以下错误。 如果我注释掉数据库连接字符串,则说明该站点加载良好。 谁能告诉我这是什么问题。
[Wed Apr 05 07:01:08.287609 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] mod_wsgi (pid=29791): Target WSGI script '/home/abhadran/test/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[Wed Apr 05 07:01:08.287675 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] mod_wsgi (pid=29791): Exception occurred processing WSGI script '/home/abhadran/test/mysite/mysite/wsgi.py'.
[Wed Apr 05 07:01:08.287705 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] Traceback (most recent call last):
[Wed Apr 05 07:01:08.287740 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] File "/home/abhadran/test/mysite/mysite/wsgi.py", line 20, in <module>
[Wed Apr 05 07:01:08.287787 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] application = get_wsgi_application()
[Wed Apr 05 07:01:08.287798 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] File "/home/abhadran/myenv/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Wed Apr 05 07:01:08.290733 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] django.setup(set_prefix=False)
[Wed Apr 05 07:01:08.290756 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] File "/home/abhadran/myenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
[Wed Apr 05 07:01:08.290779 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] apps.populate(settings.INSTALLED_APPS)
[Wed Apr 05 07:01:08.290790 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] File "/home/abhadran/myenv/lib/python3.6/site-packages/django/apps/registry.py", line 78, in populate
[Wed Apr 05 07:01:08.291738 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] raise RuntimeError("populate() isn't reentrant")
[Wed Apr 05 07:01:08.291768 2017] [wsgi:error] [pid 29791] [remote 173.1.101.95:52570] RuntimeError: populate() isn't reentrant
我的点冻结
Django==1.9.12
django-tastypie==0.13.3
mod-wsgi==4.5.15
mysql-connector-python==2.0.4
mysqlclient==1.3.10
PyMySQL==0.6
python-dateutil==2.6.0
python-mimeparse==1.6.0
requests==2.13.0
six==1.10.0
我们用来尝试连接到Mysql的数据库设置
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': 'AAAAAAAAAAAAAAAAA',
'NAME': 'ZZZZZZZZZZZZZZZZ',
'USER': 'YYYYYYYYYYYYYYYY',
'PASSWORD': 'XXXXXXXXXXXX',
'PORT': '3306',
'OPTIONS': {
'init_command': 'SET storage_engine=INNODB',
},
}
}
通常,此错误表示Django项目中某处存在错误。 可能很难找到。
您可以尝试多种解决方案,例如:1.重新启动Apache 2.执行makemigrations并迁移Django命令3.修改wsgi.py文件,以便您可以管理异常
在File "/home/abhadran/myenv/lib/python3.6/site-packages/django/apps/registry.py"
行中的一点说明表明您使用的是Python 3.6,而不是您在Python 3.5中提到的您的描述。
直到Django 1.11为止,Python 3.6才正式受支持,因此您可能必须升级Django版本或在venv中降级Python。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.