在mac中安装python依赖包gevent出现各种异常,mark一下解决过程
pip install gevent
出现以下错误
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_h/hlpk5_dd2_355l4hvkcjx19m0000gn/T/pip-install-m9tv6pok/greenlet/setup.py'"'"'; __file__='"'"'/private/var/folders/_h/hlpk5_dd2_355l4hvkcjx19m0000gn/T/pip-install-m9tv6pok/greenlet/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 /private/var/folders/_h/hlpk5_dd2_355l4hvkcjx19m0000gn/T/pip-install-m9tv6pok/greenlet/pip-egg-info
cwd: /private/var/folders/_h/hlpk5_dd2_355l4hvkcjx19m0000gn/T/pip-install-m9tv6pok/greenlet/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'egg_info'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
还有根据提示,或许setuptools 版本太旧,所以出现以下问题python setup.py egg_info Check the logs for full command output
升级setuptools
pip install --upgrade setuptools
升级后报异常
Running setup.py install for greenlet ... error
Complete output from command /Users/lluozh/work/git/swqa/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/_h/hlpk5_dd2_355l4hvkcjx19m0000gn/T/pip-install-x_14v628/greenlet/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/_h/hlpk5_dd2_355l4hvkcjx19m0000gn/T/pip-record-pys1nu76/install-record.txt --single-version-externally-managed --compile --install-headers /Users/lluozh/work/git/swqa/venv/include/site/python3.7/greenlet:
running install
running build
running build_ext
building 'greenlet' extension
creating build
creating build/temp.macosx-10.6-intel-3.7
gcc -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch i386 -arch x86_64 -g -I/Users/lluozh/work/git/swqa/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c greenlet.c -o build/temp.macosx-10.6-intel-3.7/greenlet.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
根据提示,安装gcc依赖包
pip install gcc
安装完成后,再继续安装还是报同样的错
可能是某个功能模块缺失,根据错误提示安装一些依赖的包
pip install xcrun
未能安装成功
是否pip安装模块出现异常?
pip install flask
可以正常安装,那很可能是因为安装gevent包所依赖的某些模块缺失导致了安装失败
pip可以通过直接安装whl包从方式,步骤如下:
pip install c:\gevent-1.4.0-cp37-cp37m-win_amd64.whl
尴尬的是,提示无法支持该包的安装
通过错误信息xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
发现需要在终端安装特定的包
xcode-select --install
这时再安装gevent,可安装成功
Defaulting to user installation because normal site-packages is not writeable
Collecting gevent
Using cached gevent-20.4.0-cp37-cp37m-macosx_10_9_x86_64.whl (1.8 MB)
Collecting greenlet>=0.4.14; platform_python_implementation == “CPython”
Using cached greenlet-0.4.15.tar.gz (59 kB)
Installing collected packages: greenlet, gevent
Running setup.py install for greenlet … done
Successfully installed gevent-20.4.0 greenlet-0.4.15