从源代码构建 Python 3.7

从源代码构建 Python 3.7

我正在努力在 Linux Mint 18.3 上从源代码构建 Python 3.7

gcc 存在一些问题。

我使用的 gcc 版本是否过时了?

以下是 python3.7 的 configure 脚本写入标准输出的内容

./configure
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... python3
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... gcc
checking whether the C compiler works... no
configure: error: in `/home/boldi/Downloads/Python-3.7.3':
configure: error: C compiler cannot create executables
See `config.log' for more details

当我检查 config.log 时

我发现 gcc 选项 -V 存在一些问题

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 
configure:3909: $? = 0
configure:3898: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.

答案1

从错误代码来看,发行版似乎没有该build-essential软件包。要从源代码构建 python:

  • 下载所需软件包:apt install build-essential wget ca-certificates
  • 下载最新版本源代码wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
  • 提取压缩包:tar -xf Python-3.7.3.tgz
  • cd进去
  • 配置 Makefile:./configure
  • 编译并安装:make && make install

来源:

Cpython:构建说明

相关内容