pyenv安装python常见错误

4,694 阅读1分钟

当在拿到一台新机器当时候,使用pyenv的时候,遇到如下错误:

BUILD FAILED (CentOS Linux 7 using python-build 1.2.18-8-g5e8719a)

Inspect or clean up the working tree at /tmp/python-build.20200429214155.9383
Results logged to /tmp/python-build.20200429214155.9383.log

解决方法:

# 查看错误日志信息
cat /tmp/python-build.20200429214155.9383.log

日志信息

/tmp/python-build.20200429214155.9383 ~/.pyenv
/tmp/python-build.20200429214155.9383/Python-3.7.7 /tmp/python-build.20200429214155.9383 ~/.pyenv
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.7... no
checking for python3... no
checking for python... python
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... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/python-build.20200429214155.9383/Python-3.7.7':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

其中提到gcc cc这些都是编译python所需的依赖,现在是因为缺少这些依赖而报错。

yum install -y gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel ncurses-devel libffi-devel