无法在 MacOS 11.1 上使用 pyenv 安装带有共享库的 Python 构建

时间:2021-03-09 21:30:11

标签: python macos macos-big-sur pyenv apple-m1

我在尝试安装启用了共享库的 Python 3.8.6 时遇到错误。我在 M1 Macbook Pro 上使用 PyEnv 1.2.23。

特别是,运行:

$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.8.6

返回错误信息:

python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.6.tar.xz...
-> https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tar.xz
Installing Python-3.8.6...
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/b7/nnczj7h90wn8ds7ht2ljn2l80000gn/T/python-build.20210309124942.97911
Results logged to /var/folders/b7/nnczj7h90wn8ds7ht2ljn2l80000gn/T/python-build.20210309124942.97911.log

Last 10 log lines:
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
checking size of pthread_key_t... 8
checking whether pthread_key_t is compatible with int... no
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found. Stop.

我也试过:

$ arch -x86_64 env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.8.6

我得到相同的输出。

我也试过这个:

$ brew install zlib
$ export LDFLAGS="-L/usr/local/opt/zlib/lib"
$ export CPPFLAGS="-I/usr/local/opt/zlib/include

唉,没有用。

有什么想法吗?谢谢~

1 个答案:

答案 0 :(得分:2)

M1 支持直到 3.9.1 才添加到 Python。您需要升级。