问题描述
Ubuntu 预装了 Python 2.7.2+.(我还下载了 python 开发包.)由于我遇到的另一个问题(在 如何替换/更新 Apache 使用的 expat 库的版本? ),Graham Dumpleton 告诉我我的发行版已经明确以使用外部 pyexpat 实现的方式构建 Python,因此导致了我的问题.他还说我可以从源代码自己构建 Python 来解决这个问题.我将如何在 Ubuntu 上执行此操作?(请记住,我是 Linux 新手.)
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.)
推荐答案
在 shell 提示符下(在终端中),运行
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!