当我尝试使用命令“pip3installmysqlclient”安装mysql客户机时,出现以下错误。
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/l1/f1klm_s92g53c9v2p1vrdwg80000gn/T/pip-install-a0t6svmj/mysqlclient/setup.py", line 18, in <module>
metadata, options = get_config()
File "/private/var/folders/l1/f1klm_s92g53c9v2p1vrdwg80000gn/T/pip-install-a0t6svmj/mysqlclient/setup_posix.py", line 53, in get_config
libs = mysql_config("libs_r")
File "/private/var/folders/l1/f1klm_s92g53c9v2p1vrdwg80000gn/T/pip-install-a0t6svmj/mysqlclient/setup_posix.py", line 28, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
xampp公司version:- 7.2.3.0 python:- 3.7
有人能帮我解决这个错误吗?谢谢
2条答案
按热度按时间hsvhsicv1#
确保您至少尝试过这些命令。
pip install mysql
export PATH=$PATH:/usr/local/mysql/binpip install MySQL-Python
命令是运行root
或者sudo
.如果什么都没有改变。其中一种解决方案可能会有所帮助:
试着跑步
which mysql_config
来自bash。如果找不到,请运行:locate mysql_config
. 二进制文件的文件路径需要在$path环境变量中或在中指定setup.py
对于(现在的)缺失模块。你可以尝试安装不同的软件包。有:
mysql-connector-python
或者libmysqlclient-dev
. 这个python-dev
可能会有帮助。尝试查找目录和文件
mysql/bin
,mysql_config
,和MySQL-Python
并将它们的位置添加到$path。编辑:有几个解决方案可以尝试:
apt-get install python-mysqldb
debian/ubuntu版本:sudo apt-get install libmysqlclient-dev
debian/ubuntu(2018年):sudo apt install default-libmysqlclient-dev
xampp(指定op):export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin
l0oc07j22#
要安装mysql python包,请键入以下命令:
要安装mysql connector python包,请键入以下命令:
要安装pymysql包,请键入以下命令:
代码示例