python - 无法在 macos 上使用 pyenv 安装 python 版本

标签 python macos virtualenv pyenv

我正在尝试在我的新 MacBook Pro 上使用 pyenv 安装 python 3.8.5。

我能够成功安装 pyenv 并确认它工作正常。 这很奇怪,因为我能够在我的 MacOS 上使用 pyenv 成功安装 python 3.9.2。

当我尝试安装另一个 python 版本(例如 3.8.5)时出现问题。

我收到如下错误信息。

~ » pyenv install 3.8.5
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.5.tar.xz...
-> https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
Installing Python-3.8.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.2.2 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/gm/wv5zbtxx6gl2cbg9yszmxnzc0000gn/T/python-build.20210403160603.37920
Results logged to /var/folders/gm/wv5zbtxx6gl2cbg9yszmxnzc0000gn/T/python-build.20210403160603.37920.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.

我尝试按照一些方法解决问题,如中所述

https://github.com/pyenv/pyenv/wiki/Common-build-problems (常见的构建问题)

但是,每次尝试使用 pyenv 安装 python 版本时,我都会得到相同的结果。

我是 MacOS 的新手,我想就此获得一些建议。有人可以帮忙吗?

非常感谢!

最佳答案

您遇到的错误可能是由旧版本的 xcode 命令行工具引起的。 请尝试输入并运行以下命令。它可能会改变一些东西。

xcode-select --install

LDFLAGS="-L$(xcrun --show-sdk-path)/usr/lib"pyenv 安装 3.8.5

希望对你有用。

关于python - 无法在 macos 上使用 pyenv 安装 python 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66927933/

相关文章:

javascript - -c 标志在 NodeJS 中起什么作用?

macos - Swift 显示未解析标识符 'UIAlertController' 的使用

iphone - 有使用 AppFigures.com 的经验吗?

python - 无法在使用 pyvenv-3.4 构建的虚拟环境中使用 pip 安装请求

python - Mac 使用不同的 Python 版本与 virtualenv

python - 检查 pytest 是否引发异常

python - 如果另一列中的值重复,如何获取 pandas 数据框中的最小列值?

python - R 或 Python 的分层贝叶斯

python - 如何使用 default.nix 文件运行 `nix-shell`?

virtualenv - 如何在 virtualenv 中安装 libxml2?