每次我执行python代码时,当我使用python3执行时,都会出现上述ModuleNotFound错误。使用python,它会给我一个ImportError。
我已经使用pip install --upgrade setuptools
更新了设置工具。
我还尝试了多个命令,例如:pip install mysqlclient, pip install MySQL-python, pip install pymysql
。
我也尝试了pip3的这些命令(不确定是否会有所不同)。
每次尝试这些命令时,都会出现以下错误:
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/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup_posix.py", line 51, in get_config
libs = mysql_config("libs")
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient
该如何解决?我正在使用macOS High Sierra。我已经通过了针对ubuntu / debian系统上类似问题的解决方案,并且不得不尝试在此处应用它。在Mac上,这些都不起作用。另外,我已经安装了mysql,它可以完美运行。它一直在我的系统上运行。
答案 0 :(得分:1)
您应该下载名为Mysql-python-1.2.4b4.tar.gz的tar,并将其cd
解压缩到目录中,并将文件site.cfg
:# mysql_config = /usr/local/mysql/bin/mysql_config
更新为mysql_config = /usr/local/mysql/bin/mysql_config
然后python setup.py install
,安装mysql-python之后,您将无法获取错误。