This question already has answers here:
Closed 8 months ago.
How would I build python myself from source code on Ubuntu?
(4个答案)
当我试图在Ubuntu18.04.2LTS上构建Python3时,它显示了下一个错误。
当类型:
./configure
make
make test

3个测试再次失败:
test_urllib test_urllib2 test_urllib2net
Makefile:958: recipe for target 'test' failed
make: *** [test] Error 1

有人帮我

最佳答案

首先,确保系统已完全更新:

sudo apt update
sudo apt upgrade

接下来,使用以下命令安装默认的GCC工具链:
sudo apt install build-essential

接下来,我们需要安装一些构建Python的先决条件:
sudo apt install libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev

sudo apt install libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev

在编写本文时,Python的最新稳定版本是3.7.1,如果要使用较新的版本,请相应地更改下面的说明:
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
tar xf Python-3.7.1.tar.xz
cd Python-3.7.1
./configure --enable-optimizations
make -j 8
sudo make altinstall

09-04 08:15