2017-04-05 47 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