我刚刚从 Windows 切换到 Mac 并克隆了我的存储库。我有配备新 m1 芯片的 Mac Mini 2020。
我运行 pip3 install -r requirements.txt
并收到以下错误:
ERROR: Command errored out with exit status 1:
command: /Library/Developer/CommandLineTools/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/t9/czy9qvr930l9s46j8b9k__th0000gp/T/pip-install-npqzencr/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/t9/czy9qvr930l9s46j8b9k__th0000gp/T/pip-install-npqzencr/mysqlclient/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 pip-egg-info
cwd: /private/var/folders/t9/czy9qvr930l9s46j8b9k__th0000gp/T/pip-install-npqzencr/mysqlclient/
Complete output (15 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/t9/czy9qvr930l9s46j8b9k__th0000gp/T/pip-install-npqzencr/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/private/var/folders/t9/czy9qvr930l9s46j8b9k__th0000gp/T/pip-install-npqzencr/mysqlclient/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/private/var/folders/t9/czy9qvr930l9s46j8b9k__th0000gp/T/pip-install-npqzencr/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
在看到另一篇关于此问题的帖子后,我尝试使用 sudo:
sudo pip3 install -r requirements.txt
并收到此错误:
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-jqyr1k_y/mysqlclient_c6d45690ebfd45cdbd081164dcfad4ce/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-jqyr1k_y/mysqlclient_c6d45690ebfd45cdbd081164dcfad4ce/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-h6hpe889
cwd: /private/tmp/pip-install-jqyr1k_y/mysqlclient_c6d45690ebfd45cdbd081164dcfad4ce/
Complete output (15 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/tmp/pip-install-jqyr1k_y/mysqlclient_c6d45690ebfd45cdbd081164dcfad4ce/setup.py", line 15, in <module>
metadata, options = get_config()
File "/private/tmp/pip-install-jqyr1k_y/mysqlclient_c6d45690ebfd45cdbd081164dcfad4ce/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/private/tmp/pip-install-jqyr1k_y/mysqlclient_c6d45690ebfd45cdbd081164dcfad4ce/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz#sha256=f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432 (from https://pypi.org/simple/mysqlclient/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mysqlclient==2.0.3 (from versions: 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.8, 1.3.9, 1.3.10, 1.3.11rc1, 1.3.11, 1.3.12, 1.3.13, 1.3.14, 1.4.0rc1, 1.4.0rc2, 1.4.0rc3, 1.4.0, 1.4.1, 1.4.2, 1.4.2.post1, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 2.0.0, 2.0.1, 2.0.2, 2.0.3)
ERROR: No matching distribution found for mysqlclient==2.0.3
版本: 蟒蛇 2.7.16 点 19.2.3 当我运行检查我的 pip 版本时,它清楚地显示了 python 3.8:
pip3 --version
pip 19.2.3 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
任何提示都很棒!
答案 0 :(得分:1)
我对 M1 也有类似的经历。我认为这是由于 mysql 配置。因此,首先找到您的 mysql_config
所在的位置(它可以位于 /opt
或 /bin
目录中)。例如我在:
/opt/homebrew/bin
找到该文件后,您需要使用您喜欢的编辑器(我使用 nano
)编辑该文件并在配置中更改这一行:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
改成这样:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
编辑后再次安装 mysqlclient
。您还可以确保 gcc
已安装在您的 Mac 上