首页 > 解决方案 > 使用 pyenv 安装特定的 python 版本

问题描述

我正在使用 MAC 进行开发工作并安装了 pyenv 来安装不同的 python 版本。我已经安装了 3.7,现在尝试使用 pyenv 安装 python 3.9.0。但它失败了。

下面是终端输出:

Mahbubs-MBP:~ rahman$ pyenv install 3.9.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
python-build: use readline from homebrew

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

Inspect or clean up the working tree at /var/folders/8p/v01dm57j2yv99fckz16cv5m00000gn/T/python-build.20210827122107.61252
Results logged to /var/folders/8p/v01dm57j2yv99fckz16cv5m00000gn/T/python-build.20210827122107.61252.log

Last 10 log lines:
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/8p/v01dm57j2yv99fckz16cv5m00000gn/T/python-build.20210827122107.61252/Python-3.9.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

我是否应该使用 brew 安装一些其他必需的软件包以使其工作?有什么建议吗?

标签: pythonmacospyenv

解决方案


推荐阅读