簡體   English   中英

MySQL無法與Python 3.6和Django 1.9一起使用

[英]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。

相關職位:- 職位1- 職位2- 職位3- 職位4- 職位5

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM