[当我使用pip安装mysqlclient时出现错误[重复]

问题描述 投票:0回答:2
我正在尝试使用pip安装mysqlclient,但是它一直遇到错误。我已经看到一些建议,告诉我确保mysqlclient中的python版本是最新的。我已经做到了。推送到mysqlclient master之后,我运行了install命令,但是它给了我以下错误。

如何解决此错误?

pip install mysqlclient

错误:

(base) brijesh:~ sierra$ pip install mysqlclient Collecting mysqlclient Using cached mysqlclient-1.4.6.tar.gz (85 kB) Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... error ERROR: Command errored out with exit status 1: command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-wheel-yu73tf06 cwd: /private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/ Complete output (30 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.7 creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.9-x86_64-3.7 creating build/temp.macosx-10.9-x86_64-3.7/MySQLdb gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include -arch x86_64 -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/local/mysql/include -I/opt/anaconda3/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o xcrun: error: active developer path ("/Applications/Xcode 9.1.app/Contents/Developer") does not exist Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools. See `man xcode-select` for more details. error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error ERROR: Command errored out with exit status 1: command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-record-xce3nbnm/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.7m/mysqlclient cwd: /private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/ Complete output (30 lines): running install running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.7 creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.9-x86_64-3.7 creating build/temp.macosx-10.9-x86_64-3.7/MySQLdb gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/anaconda3/include -arch x86_64 -I/opt/anaconda3/include -arch x86_64 -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/local/mysql/include -I/opt/anaconda3/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o xcrun: error: active developer path ("/Applications/Xcode 9.1.app/Contents/Developer") does not exist Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools. See `man xcode-select` for more details. error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-install-8qoawh1_/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/pm/gmghbq8960bgdq9hk_bx25qc0000gn/T/pip-record-xce3nbnm/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.7m/mysqlclient Check the logs for full command output.

python django terminal pip mysql-python
2个回答
0
投票
您似乎正在使用anaconda,因为您的python位于/opt/anaconda3/bin/python,因此您应该更喜欢使用conda命令进行安装:

conda install mysqlclient

话虽这么说,您最初的问题似乎与xcode有关,但您的错误建议继续运行

xcode-select --install

尽管我不是Apple用户,并且对在MacOS上安装正确的开发工具不太熟悉。如果上述方法不起作用,您也可以考虑在http://apple.stackexchange.com处提问

-1
投票
sudo apt-get install libssl-dev pip install mysqlclient
这可能是一个重复的问题,起源是:Python 3.7, Failed building wheel for MySql-Python
© www.soinside.com 2019 - 2024. All rights reserved.