如何解决Pyenv 无法在 mac
我正在尝试在 macOS Big Sur(11.1) 上安装 python3.5.2
3.5.2 安装日志
python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-3.5.2...
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3439 (offset 13 lines).
patching file configure.ac
Hunk #1 succeeded at 490 (offset -20 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 11.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/2d/jw08s7rx35d25b3lj52kr68r0000gn/T/python-build.20201223151024.74644
Results logged to /var/folders/2d/jw08s7rx35d25b3lj52kr68r0000gn/T/python-build.20201223151024.74644.log
Last 10 log lines:
Python/random.c:97:19: note: did you mean 'py_getentropy'?
Python/random.c:89:1: note: 'py_getentropy' declared here
py_getentropy(unsigned char *buffer,Py_ssize_t size,int fatal)
^
Python/random.c:106:19: error: implicit declaration of function 'getentropy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
res = getentropy(buffer,len);
^
2 errors generated.
make: *** [Python/random.o] Error 1
make: *** Waiting for unfinished jobs....
我试过了,重新安装pyenv
、readline
、make
、camke
、xz
、bzip2
、zlib
我写了.zshrc
我的 .zshrc 文件
...
# pyenv settings
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# The usual `pyenv init` stuff
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
if [[ "$(uname -s)" == "Darwin" ]] ; then
# Adopted SDK workaround from @marcosgomesborges
[[ -n "$MACOSX_DEPLOYMENT_TARGET" ]] || export MACOSX_DEPLOYMENT_TARGET="$(sw_vers -productVersion | cut -c -5)" # e.g.: 10.14
[[ -n "$SDKROOT" ]] || export SDKROOT="$(xcrun --show-sdk-path)"
# Workaround for OpenSSL header/library paths (for GCC & LINKER)
pfx_openssl="$(brew --prefix openssl)" # Change this if openssl was not installed via homebrew
if [[ -d "$pfx_openssl" ]] ; then
export CPATH="${pfx_openssl}/include:${CPATH}" # Headers for C pre-processor
export LIBRARY_PATH="${pfx_openssl}/lib:${LIBRARY_PATH}" # libraries (for the linker)
fi
fi
# zlib && bzip2 settings
export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"
...
解决方法
提供 CFLAGS -
$ CFLAGS="-I$(xcrun --show-sdk-path)/usr/include"
,
LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.5.10 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。