在macOS中设置django和MySQL时出现错误。这是我到目前为止尝试过的
python manage.py runserver 0:8000
...
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
pip install mysqlclient
Requirement already satisfied: mysqlclient in ./venv/lib/python3.7/site-packages (1.4.2.post1)
WARNING: You are using pip version 19.3; however, version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pip install mysql-python
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
ERROR: Command errored out with exit status 1:
command: /Users/Neil/Documents/GitHub/yas/venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/q1/4yk86bss76s8zd27j30mnlr40000gn/T/pip-install-ciyk1caf/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/q1/4yk86bss76s8zd27j30mnlr40000gn/T/pip-install-ciyk1caf/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/q1/4yk86bss76s8zd27j30mnlr40000gn/T/pip-install-ciyk1caf/mysql-python/pip-egg-info
cwd: /private/var/folders/q1/4yk86bss76s8zd27j30mnlr40000gn/T/pip-install-ciyk1caf/mysql-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/q1/4yk86bss76s8zd27j30mnlr40000gn/T/pip-install-ciyk1caf/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/q1/4yk86bss76s8zd27j30mnlr40000gn/T/pip-install-ciyk1caf/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.3; however, version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pip install mysqlclient
Requirement already satisfied: mysqlclient in ./venv/lib/python3.7/site-packages (1.4.2.post1)
WARNING: You are using pip version 19.3; however, version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
这是pip冻结的输出(有configparser)
certifi==2019.9.11
chardet==3.0.4
configparser==4.0.2
defusedxml==0.6.0
Django==2.2.3
django-ckeditor==5.7.1
django-crispy-forms==1.7.2
django-environ==0.4.5
django-extensions==2.2.1
django-js-asset==1.2.2
django-map-widgets==0.2.2
django-model-utils==3.2.0
django-post-office==3.2.1
django-rest-framework==0.1.0
djangorestframework==3.10.3
easy-thumbnails==2.6
idna==2.8
jsonfield==2.0.2
mysql-connector==2.2.9
mysqlclient==1.4.2.post1
oauthlib==3.1.0
Pillow==5.1.0
PyJWT==1.7.1
PyMySQL==0.9.3
python3-openid==3.1.0
pytz==2019.3
requests==2.22.0
requests-oauthlib==1.2.0
six==1.12.0
social-auth-app-django==3.1.0
social-auth-core==3.2.0
sqlparse==0.3.0
urllib3==1.25.6
我在论坛上花费了很多时间,但是在这种情况下,没有其他选择可以帮助我。如果您按照主要文档站点上的说明进行操作,设置django和mysql是如此困难,这很奇怪。