Ubuntu 预装了 Python 2.7.2+。 (我还下载了 python 开发包。)由于我遇到的另一个问题(在 How do I replace/update the version of the expat library used by Apache? 中进行了深入解释),Graham Dumpleton 告诉我我的发行版明确构建了 Python 以使用外部 pyexpat 实现,所以导致我的问题。他还说我可以自己从源代码构建 Python 来解决这个问题。我将如何在 Ubuntu 上执行此操作? (请记住,我是 Linux 新手。)
最佳答案
在 shell 提示符下(在终端中),运行
sudo apt-get install build-essential
这将获取构建任何东西所需的所有常用包(例如编译器等)。
然后运行
sudo apt-get build-dep python2.7
这将获取构建 python 所需的所有库。
然后下载python的源代码并解压到一个目录中。
去那里跑
./configure --prefix=/path/where/you/want/python/installed
然后是 make
然后 make install
来构建和安装它:
make && make install
如果您在途中遇到障碍,请在此处询问,我会尽力提供一些指导。
https://stackoverflow.com/questions/8097161/