gpt4 book ai didi

python - MYSQL-python pip安装错误

转载 作者:可可西里 更新时间:2023-11-01 07:11:21 28 4
gpt4 key购买 nike

我试图在 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/

我该如何解决这个问题?

最佳答案

MySQL-python

MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currently supported. Python-3.0 will be supported in a future release.

你可以安装mysqlclient或者pymysql,我更喜欢后者:

pip install pymysql

并将此添加到您的manage.py:

import pymysql
pymysql.install_as_MySQLdb()

关于python - MYSQL-python pip安装错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42357853/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com