【发布时间】:2020-03-26 00:06:01
【问题描述】:
有很多类似的问题,但都有不同的解决方案。它们都不适合我。
我正在尝试为 Django 项目安装 Mysql 连接器,但出现以下错误。
首先我安装了最新版本的 Django。 然后用下面的代码安装mysql
brew install mysql - 工作正常。
那么这是我正在尝试安装连接器的代码。
pip3 mysql-python。之前使用easy_install mysql-python,但两者都不起作用。
Python 版本:3.8.0
Django 版本:2.2.7
MySql 版本:8.0.18
pip3 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: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/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/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/pip-egg-info
cwd: /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/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.
【问题讨论】:
-
在 Mac 上尝试这里的步骤,它以前对我有帮助:ruddra.com/posts/install-mysqlclient-macos 它建议安装 mysqlclient 而不是 mysql-python
-
嗨@EdoardoFacchinelli,我一步一步尝试,但在
pip install mysqlclient上失败了。我也试过pip3,但没有用。错误信息太长。这是一些部分:Complete output (12 lines): /bin/sh: mysql_config: command not found /bin/sh: mariadb_config: command not found /bin/sh: mysql_config: command not found Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-pzdweaop/mysqlclient/setup.py", line 16, in <module> metadata, options -
@EdoardoFacchinelli 在 step=
brew link --overwrite mysql-connector-c中使用--force后,我终于能够运行pip install mysqlclient。但我仍然有连接到数据库的问题。错误代码太长,无法评论,但结尾是:raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.