我试图在 Django 上构建一个应用程序,我想使用 MySQL 作为数据库。对settings.py设置好后,我尝试迁移。然后我得到一个明显的错误,说没有安装 MySQL。所以为了安装 MySQL,我运行了:
sudo -H pip install MySQL-python
我收到以下错误:
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-zAMhWo/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-zAMhWo/MySQL-python/
我该如何解决?
原文由 JGCW 发布,翻译遵循 CC BY-SA 4.0 许可协议
MySQL-python
你可以安装 mysqlclient 或 pymysql,我更喜欢后者:
并将其添加到您的
manage.py
: