尝试通过以下方式安装 python 3:
LDFLAGS="-L/opt/local/lib/" CPPFLAGS="-I/opt/local/include -L/opt /local/lib" C_INCLUDE_PATH="/opt/local/include" LIBRARY_PATH=" /opt/local/lib" pyenv install 3.7.3
我得到:
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew
BUILD FAILED (OS X 10.15.4 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/qg/bfsy6h2j1_76gh41ngnnwgdh0000gn/T/python-build.20200508155826.1859
Results logged to /var/folders/qg/bfsy6h2j1_76gh41ngnnwgdh0000gn/T/python-build.20200508155826.1859.log
Last 10 log lines:
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/qg/bfsy6h2j1_76gh41ngnnwgdh0000gn/T/python-build.20200508155826.1859/Python-3.7.3':
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
此问题的其他解决方案不太相同我还没有看到与 pyenv 相关的此错误,有任何线索吗?我以前用自制程序安装了 python3,但考虑到日志中的错误,我怀疑这是罪魁祸首。
我安装了命令行工具。
如果您使用 WSL2 ubuntu 并通过 homebrew 安装 pyenv,解决此问题的一种方法是安装
build-essential
及其朋友。
sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
参考。 pyenv 官方指南。它还有 linuxbrew、macOS、其他操作系统。
正如错误所说:
检查或清理位于 /var/folders/qg/bfsy6h2j1_76gh41ngnnwgdh0000gn/T/python-build.20200508155826.1859 的工作树
并且:
有关更多详细信息,请参阅“config.log”
所以人们基本上需要调查一下
/var/folders/qg/bfsy6h2j1_76gh41ngnnwgdh0000gn/T/python-build.20200508155826.1859/config.log
。
由于
checking whether the C compiler works
时失败,请在文件中查找此文本:错误原因应在下面描述。