2017-04-05 62 views
0

我想连接mysql db和django 1.9并且python版本是3.6。有了数据库连接字符串,我得到了下面的错误。如果我注释掉数据库连接字符串,网站加载正常。有人可以告诉这是什么错误。Mysql不能使用python 3.6和django 1.9

[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 

DB设置,我们使用的是尝试连接到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', 
     }, 
    } 
} 
+0

你为什么要装*三个*独立的MySQL客户端库?那些是替代品。 –

+0

尽管如此,除非您显示您的实际设置,否则我们无能为力。 –

+0

什么设置是必需的,它是wsgi还是虚拟配置设置 – Anish

回答

0

通常,这种错误意味着在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。

相关文章: - Post 1 - Post 2 - Post 3 - Post 4 - Post 5