python - 配置:错误:尝试使用 pyenv 安装 python 时,C 编译器无法创建可执行文件
问题描述
尝试通过以下方式安装 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 openssl@1.1 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 和其他操作系统。
推荐阅读
- python - 从 bash 到 GO 服务器的 REST 发布查询有效,但 Python 失败
- angular - 无法读取属性“地图” - Angular 6 的生产版本
- php - 数组递归 PHP 和 MYSQL 中的顺序数组
- sql-server - 全文索引遇到错误代码 3602 并且搜索不起作用
- android - Kotlin Android Extensions 和 AndroidX 似乎没有正确投射
- gulp - Gulp 任务 - 包括目标文件夹
- php - 俄语字符和字母数字转换器
- python - Keras 矩阵乘法得到预测值
- reactjs - 如何从按钮更新此组件
- python - 如何在 Python 中执行矢量化操作?