Mac OS Big Sur上通过pyenv的python 3.6安装失败
在我的MacOS Big Sur上安装Python 3.6.13时,使用命令pyenv install 3.6.13,出现以下错误
MacBook-Pro-2:cache fancy$ pyenv install 3.6.5
python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-3.6.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdkBUILD FAILED (OS X 11.4 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/jv/jhykqkbn709g4pcn4978jxyc0000gn/T/python-build.20210812173758.79132
Results logged to /var/folders/jv/jhykqkbn709g4pcn4978jxyc0000gn/T/python-build.20210812173758.79132.logLast 10 log lines:
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = sendfile(in, out, offset, &sbytes, &sf, flags);
^
./Modules/posixmodule.c:10432:5: warning: code will never be executed [-Wunreachable-code]
Py_FatalError("abort() called from Python code didn't abort!");
^~~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.
解决的办法:
- brew reinstall zlib bzip2
- sudo rm -rf /Library/Developer/CommandLineTools
- xcode-select --install
- CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.5 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)