在 RHEL 上安装 Python 3
我正在尝试使用以下步骤在 RHEL 上安装 python3:
I'm trying to install python3 on RHEL using the following steps:
yum search python3
返回找不到匹配项:python3
关注:
yum search python
没有一个搜索结果包含 python3.接下来我应该尝试什么?
None of the search results contained python3. What should I try next?
手动安装很容易:
下载(Python.org 上可能有更新的版本):
Download (there may be newer releases on Python.org):
$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
解压
Unzip
$ tar xf Python-3.*
$ cd Python-3.*
准备编译
Prepare compilation
$ ./configure
构建
Build
$ make
安装
Install
$ make install
或者,如果您不想覆盖 python
可执行文件(更安全,至少在某些发行版上 yum
需要 python
为 2.x,例如 RHEL6) - 您可以使用 altinstall
将 python3.*
作为并发实例安装到系统默认:
OR if you don't want to overwrite the python
executable (safer, at least on some distros yum
needs python
to be 2.x, such as for RHEL6) - you can install python3.*
as a concurrent instance to the system default with an altinstall
:
$ make altinstall
现在如果你想要一个替代的安装目录,你可以将 --prefix
传递给 configure
命令.
Now if you want an alternative installation directory, you can pass --prefix
to the configure
command.
示例:要在/opt/local 中安装"Python,只需添加 --prefix=/opt/local
.
Example: for 'installing' Python in /opt/local, just add --prefix=/opt/local
.
在 make install
步骤之后:为了使用新的 Python 安装,您可能仍然需要将 [prefix]/bin 添加到 $PATH
和 [prefix]/lib 到 $LD_LIBRARY_PATH
(取决于您传递的 --prefix
)
After the make install
step: In order to use your new Python installation, it could be, that you still have to add the [prefix]/bin to the $PATH
and [prefix]/lib to the $LD_LIBRARY_PATH
(depending of the --prefix
you passed)