gpt4 book ai didi

python - 同一台机器上有多个 Python 版本?

转载 作者:IT老高 更新时间:2023-10-28 21:38:39 25 4
gpt4 key购买 nike

Python 网站上是否有官方文档,关于如何在 Linux 上的同一台机器上安装和运行多个版本的 Python?

我可以找到数以百万计的博客文章和答案,但我想知道是否有“标准”的官方方式来做到这一点?

或者这一切都依赖于操作系统?

最佳答案

我认为它是完全独立的。只需安装它们,然后你就有了命令,例如/usr/bin/python2.5/usr/bin/python2.6。将 /usr/bin/python 链接到您要默认使用的那个。

无论如何,所有库都在单独的文件夹中(以版本命名)。

如果你想手动编译版本,这来自 Python 源代码的自述文件:

Installing multiple versions

On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall".

For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.

关于python - 同一台机器上有多个 Python 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2547554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com