如何在Ubuntu上从源代码自己构建python? [英] How would I build python myself from source code on Ubuntu?
问题描述
Ubuntu预先安装了Python 2.7.2+. (我还下载了python dev软件包.)由于我遇到的另一个问题(在
Ubuntu comes with Python 2.7.2+ pre-installed. (I also downloaded the python dev packages.) Because of another issue I'm having (Explained in extreme depth in How do I replace/update the version of the expat library used by Apache? ), Graham Dumpleton told me my distro had explicitly built Python in a way to use an external pyexpat implementation, so causing my issue. He also said I could build Python myself from source code to resolve the issue. How would I do this on Ubuntu? (Keep in mind I'm new to Linux.)
推荐答案
-
在外壳程序提示符下(在终端中)运行
At a shell prompt (in a terminal), run
sudo apt-get install build-essential
这将获取构建任何东西所需的所有常用软件包(例如编译器等).
This will fetch all the common packages you need to build anything (e.g. the compiler etc.).
然后运行
sudo apt-get build-dep python2.7
这将获取构建python所需的所有库.
This will fetch all the libraries you need to build python.
然后下载python的源代码并将其解压缩到目录中.
Then download the source code for python and decompress it into a directory.
去那里奔跑
./configure --prefix=/path/where/you/want/python/installed
然后依次make
和make install
进行构建和安装:
Then make
and then make install
to get it built and installed:
make && make install
如果您在途中遇到障碍,请在这里提问,我将尽力提供一些指导.
If you hit snags on the way, ask back here and I'll try to offer some guidance.
这篇关于如何在Ubuntu上从源代码自己构建python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!