在 RHEL 上安装 Python 3

发布于 2024-12-15 00:37:32 字数 228 浏览 5 评论 0 原文

我正在尝试使用以下步骤在 RHEL 上安装 python3:

yum search python3

返回 No matches find for: python3

其次:

yum search python

搜索结果均不包含 python3。接下来我应该尝试什么?

I'm trying to install python3 on RHEL using the following steps:

yum search python3

Which returned No matches found for: python3

Followed by:

yum search python

None of the search results contained python3. What should I try next?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(19

暮色兮凉城 2024-12-22 00:37:32

从 RPM 安装通常更好,因为:

  • 您可以(正确)安装和卸载 python3。
  • 安装时间更快。如果您在具有多个虚拟机的云环境中工作,则在每个虚拟机上编译 python3 是不可接受的。

解决方案 1:红帽和EPEL 存储库

Red Hat 通过 EPEL 存储库添加了:

  • Python 3.4 for CentOS 6
  • Python 3.6 for CentOS 7

[EPEL] 如何安装 Python 3.4在 CentOS 6 上

sudo yum install -y epel-release
sudo yum install -y python34

# Install pip3
sudo yum install -y python34-setuptools  # install easy_install-3.4
sudo easy_install-3.4 pip

您可以使用 pyvenv 创建您的 virtualenv

pyvenv /tmp/foo

[EPEL] 如何在 CentOS 7 上安装 Python

3.6 CentOS7,pip3.6 作为软件包提供:)

sudo yum install -y epel-release
sudo yum install -y python36 python36-pip

您可以使用 pyvenv 创建您的 virtualenv

python3.6 -m venv /tmp/foo

如果您使用 pyvenv< /code> 脚本,您将收到警告:

$ pyvenv-3.6 /tmp/foo
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv`

解决方案 2:IUS 社区存储库

IUS 社区为 RHEL 和 Linux 提供了一些最新的软件包。 CentOS。背后的人来自 Rackspace,所以我认为他们非常值得信赖...

https://ius.io/

在这里检查适合您的存储库:

https://ius.io/setup

[IUS] 如何安装 Python 3.6在 CentOS 6 上

sudo yum install -y https://repo.ius.io/ius-release-el6.rpm
sudo yum install -y python36u python36u-pip

您可以创建您的virtualenv 使用 pyvenv

python3.6 -m venv /tmp/foo

[IUS] 如何在 CentOS 7 上安装 Python 3.6

sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-pip

您可以使用 pyvenv 创建您的 virtualenv :

python3.6 -m venv /tmp/foo

Installing from RPM is generally better, because:

  • you can install and uninstall (properly) python3.
  • the installation time is way faster. If you work in a cloud environment with multiple VMs, compiling python3 on each VMs is not acceptable.

Solution 1: Red Hat & EPEL repositories

Red Hat has added through the EPEL repository:

  • Python 3.4 for CentOS 6
  • Python 3.6 for CentOS 7

[EPEL] How to install Python 3.4 on CentOS 6

sudo yum install -y epel-release
sudo yum install -y python34

# Install pip3
sudo yum install -y python34-setuptools  # install easy_install-3.4
sudo easy_install-3.4 pip

You can create your virtualenv using pyvenv:

pyvenv /tmp/foo

[EPEL] How to install Python 3.6 on CentOS 7

With CentOS7, pip3.6 is provided as a package :)

sudo yum install -y epel-release
sudo yum install -y python36 python36-pip

You can create your virtualenv using pyvenv:

python3.6 -m venv /tmp/foo

If you use the pyvenv script, you'll get a WARNING:

$ pyvenv-3.6 /tmp/foo
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv`

Solution 2: IUS Community repositories

The IUS Community provides some up-to-date packages for RHEL & CentOS. The guys behind are from Rackspace, so I think that they are quite trustworthy...

https://ius.io/

Check the right repo for you here:

https://ius.io/setup

[IUS] How to install Python 3.6 on CentOS 6

sudo yum install -y https://repo.ius.io/ius-release-el6.rpm
sudo yum install -y python36u python36u-pip

You can create your virtualenv using pyvenv:

python3.6 -m venv /tmp/foo

[IUS] How to install Python 3.6 on CentOS 7

sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-pip

You can create your virtualenv using pyvenv:

python3.6 -m venv /tmp/foo
昨迟人 2024-12-22 00:37:32

手动安装 python 很容易(即从源代码构建):

  1. 下载(Python 上可能有更新的版本.org):

    <预> <代码> $ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz

  2. 解压

    <前><代码> $ tar xf Python-3.*
    $ cd Python-3.*

  3. 准备编译

    <预置><代码> $ ./configure

  4. 构建

    <前><代码> $ make

  5. 安装

    <前><代码> $ make install

    或者,如果您不想覆盖 python 可执行文件(更安全,至少在某些发行版上 yum 需要 python 为 2 .x,例如 RHEL6) - 您可以使用 altinstallpython3.* 安装为系统默认的并发实例:

    <预置><代码> $ make altinstall

现在,如果您想要替代安装目录,您可以经过--prefixconfigure 命令。

示例:要在 /opt/local 中“安装”Python,只需添加 --prefix=/opt/local

make install 步骤之后:为了使用新安装的 Python,您可能仍然需要将 [prefix]/bin 添加到 $PATH 并[prefix]/lib 到 $LD_LIBRARY_PATH (取决于您传递的 --prefix

It is easy to install python manually (i.e. build from source):

  1. 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
    
  2. Unzip

     $ tar xf Python-3.* 
     $ cd Python-3.*
    
  3. Prepare compilation

     $ ./configure
    
  4. Build

     $ make
    
  5. Install

     $ make install
    

    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
    

Now if you want an alternative installation directory, you can pass --prefix to the configurecommand.

Example: for 'installing' Python in /opt/local, just add --prefix=/opt/local.

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)

雨的味道风的声音 2024-12-22 00:37:32

除了gecco的答案之外,我会将步骤3从: 更改

./configure

为:

./configure --prefix=/opt/python3

然后安装后您还可以:

# ln -s /opt/python3/bin/python3 /usr/bin/python3

这是为了确保安装不会与使用yum安装的python发生冲突。

请参阅我在互联网上找到的解释:

http ://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source

In addition to gecco's answer I would change step 3 from:

./configure

to:

./configure --prefix=/opt/python3

Then after installation you could also:

# ln -s /opt/python3/bin/python3 /usr/bin/python3

It is to ensure that installation will not conflict with python installed with yum.

See explanation I have found on Internet:

http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source

表情可笑 2024-12-22 00:37:32

除了 Python 2.7 和 3.3 之外,红帽软件集合现在还包括 Python 3.4 - 所有这些都可以在 RHEL 6 和 7 上运行。RHSCL

2.0 文档位于 https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/

另外还有很多文章位于developerblog.redhat.com。

使用 SCL yum 存储库可能比其他 yum 存储库更好,因为 RPM 是由 Redhat 开发/测试的(即第一方 RPM 而不是第三方) )。

编辑

遵循这些在 RHEL 6/7 或 CentOS 6/7 上安装 Python 3.4 的说明

# 1. Install the Software Collections tools:
yum install scl-utils

# 2. Download a package with repository for your system.
#  (See the Yum Repositories on external link. For RHEL/CentOS 6:)
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-6-x86_64/download/rhscl-rh-python34-epel-6-x86_64.noarch.rpm
#  or for RHEL/CentOS 7
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm

# 3. Install the repo package (on RHEL you will need to enable optional channel first):
yum install rhscl-rh-python34-*.noarch.rpm

# 4. Install the collection:
yum install rh-python34

# 5. Start using software collections:
scl enable rh-python34 bash

更新 2021-08-16:

  • rhelcentos 版本 7 现在默认使用 python 3.6,我相信
  • 截至本文撰写之日 2021 年 8 月 16 日,SCL yum 存储库已经有 python 版本 3.8(尽管该问题仍然引用旧的 python 3.4 版本)

Along with Python 2.7 and 3.3, Red Hat Software Collections now includes Python 3.4 - all work on both RHEL 6 and 7.

RHSCL 2.0 docs are at https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/

Plus lot of articles at developerblog.redhat.com.

<opinion> Using the SCL yum repos may be better than other yum repos because the RPMs are developed/tested by Redhat (i.e. first-party RPMs instead of third-party). </opinion>

edit

Follow these instructions to install Python 3.4 on RHEL 6/7 or CentOS 6/7:

# 1. Install the Software Collections tools:
yum install scl-utils

# 2. Download a package with repository for your system.
#  (See the Yum Repositories on external link. For RHEL/CentOS 6:)
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-6-x86_64/download/rhscl-rh-python34-epel-6-x86_64.noarch.rpm
#  or for RHEL/CentOS 7
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm

# 3. Install the repo package (on RHEL you will need to enable optional channel first):
yum install rhscl-rh-python34-*.noarch.rpm

# 4. Install the collection:
yum install rh-python34

# 5. Start using software collections:
scl enable rh-python34 bash

UPDATE 2021-08-16:

  • rhel and centos version 7 are now on python 3.6 by default i believe
  • the SCL yum repo has python version 3.8 as of the date of this writing 2021-08-16 (despite the question still referencing the older python 3.4 version)
红尘作伴 2024-12-22 00:37:32

使用 SCL 存储库。

sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python33.repo >> /etc/yum.repos.d/scl.repo'
sudo yum install python33
scl enable python27

(每次您想要使用 python27 而不是系统默认值时,都必须运行最后一个命令。)

Use the SCL repos.

sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python33.repo >> /etc/yum.repos.d/scl.repo'
sudo yum install python33
scl enable python27

(This last command will have to be run each time you want to use python27 rather than the system default.)

昇り龍 2024-12-22 00:37:32

Python3 最近作为 Python34 添加到 EPEL7。

目前正在努力制定关于如何在 EPEL7 中为 Python3 打包内容的打包指南。

请参阅 https://bugzilla.redhat.com/show_bug.cgi?id=1219411
https://lists.fedoraproject.org/pipermail/python-devel/2015-July /000721.html

Python3 was recently added to EPEL7 as Python34.

There is ongoing (currently) effort to make packaging guidelines about how to package things for Python3 in EPEL7.

See https://bugzilla.redhat.com/show_bug.cgi?id=1219411
and https://lists.fedoraproject.org/pipermail/python-devel/2015-July/000721.html

咽泪装欢 2024-12-22 00:37:32

您可以从以下位置下载 RHEL6 / CentOS6 的源 RPM 和二进制 RPM:
此处

这是最新 Fedora 开发的反向移植
源 rpm 到 RHEL6 / CentOS6

You can download a source RPMs and binary RPMs for RHEL6 / CentOS6 from
here

This is a backport from the newest Fedora development
source rpm to RHEL6 / CentOS6

浪菊怪哟 2024-12-22 00:37:32

如果您使用 RHEL 并且想要 Red Hat 支持的 Python,请使用 Red Hat Software Collections (RHSCL)。 Red Hat 不支持 EPEL 和 IUS 软件包。另外,上面的许多答案都指向 CentOS 软件集合。虽然您可以安装这些软件包,但它们不是 RHEL 的 Red Hat 支持的软件包。

另外,投票最高的答案给出了不好的建议 - 在 RHEL 上,您不想更改 /usr/bin/python/usr/bin/python2 因为您可能会破坏yum 和其他 RHEL 管理工具。看一下/bin/yum,它是一个以#!/usr/bin/python开头的Python脚本。如果您从源代码编译 Python,请勿以 root 身份执行 make install。这将覆盖 /usr/bin/python。如果您破坏了 yum,则恢复系统可能会很困难。

有关更多信息,请参阅如何安装 Python 3、pip、venv developers.redhat.com 上 RHEL 上的 virtualenv 和 pipelinev。它涵盖了从 RHSCL 安装和使用 Python 3、使用 Python 虚拟环境以及在 RHEL 上使用软件集合和使用 Python 的一些技巧。

简而言之,要通过 Red Hat 软件集合安装 Python 3.6:

$ su -
# subscription-manager repos --enable rhel-7-server-optional-rpms \
   --enable rhel-server-rhscl-7-rpms
# yum -y install @development
# yum -y install rh-python36

# yum -y install rh-python36-numpy \
   rh-python36-scipy \ 
   rh-python36-python-tools \
   rh-python36-python-six

要使用软件集合,您必须启用它:

scl enable rh-python36 bash

但是,如果您希望永久启用 Python 3,您可以将以下内容添加到 ~/.bashrc,然后注销并再次回来。现在,Python 3 已永久在您的路径中。

# Add RHSCL Python 3 to my login environment
source scl_source enable rh-python36

注意:执行此操作后,输入 python 现在将为您提供 Python 3.6,而不是 Python 2.7。

有关所有这些内容以及更多详细信息,请参阅上面的文章。

If you are on RHEL and want a Red Hat supported Python, use Red Hat Software collections (RHSCL). The EPEL and IUS packages are not supported by Red Hat. Also many of the answers above point to the CentOS software collections. While you can install those, they aren't the Red Hat supported packages for RHEL.

Also, the top voted answer gives bad advice - On RHEL you do not want to change /usr/bin/python, /usr/bin/python2 because you will likely break yum and other RHEL admin tools. Take a look at /bin/yum, it is a Python script that starts with #!/usr/bin/python. If you compile Python from source, do not do a make install as root. That will overwrite /usr/bin/python. If you break yum it can be difficult to restore your system.

For more info, see How to install Python 3, pip, venv, virtualenv, and pipenv on RHEL on developers.redhat.com. It covers installing and using Python 3 from RHSCL, using Python Virtual Environments, and a number of tips for working with software collections and working with Python on RHEL.

In a nutshell, to install Python 3.6 via Red Hat Software Collections:

$ su -
# subscription-manager repos --enable rhel-7-server-optional-rpms \
   --enable rhel-server-rhscl-7-rpms
# yum -y install @development
# yum -y install rh-python36

# yum -y install rh-python36-numpy \
   rh-python36-scipy \ 
   rh-python36-python-tools \
   rh-python36-python-six

To use a software collection you have to enable it:

scl enable rh-python36 bash

However if you want Python 3 permanently enabled, you can add the following to your ~/.bashrc and then log out and back in again. Now Python 3 is permanently in your path.

# Add RHSCL Python 3 to my login environment
source scl_source enable rh-python36

Note: once you do that, typing python now gives you Python 3.6 instead of Python 2.7.

See the above article for all of this and a lot more detail.

岁月染过的梦 2024-12-22 00:37:32

我看到所有的答案都是要求从代码编译 python3 或安装二进制 RPM 包。这是启用 EPEL (Extra Packages for Enterprise Linux) 然后使用 yum 安装 python 的另一个答案。 RHEL 7.5 (Maipo) 的步骤

yum install wget –y
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-XX.noarch.rpm # Verify actual RPM name by browsing dir over browser
rpm –ivh epel-*.rpm
yum install python36

另请参阅链接

I see all the answers as either asking to compile python3 from code or installing the binary RPM package. Here is another answer to enable EPEL (Extra Packages for Enterprise Linux) and then install python using yum. Steps for RHEL 7.5 (Maipo)

yum install wget –y
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-XX.noarch.rpm # Verify actual RPM name by browsing dir over browser
rpm –ivh epel-*.rpm
yum install python36

Also see link

So要识趣 2024-12-22 00:37:32

我在使用 python 2.7 时遇到了同样的问题。按照以下步骤成功升级到3.6。
您也可以尝试这个 -

  1. 升级前查看版本是 2.x

    <前><代码>python --版本
    Python 2.7.5

  2. 使用下面的命令将你的python升级到3.x版本-

    yum 安装 python3x

    x 替换为您想要的版本号。

    ie安装python 3.6执行

    yum 安装 python36
    
  3. 之后,如果您想将此 python 设置为默认版本,则在 bashrc 文件中添加

    vi ~/.bashrc

    别名 python='python3.6'
    
  4. 执行 bash 命令以应用设置

    <前><代码>bash

  5. 现在你可以看到下面的版本

    <前><代码>python --版本
    Python 3.6.3

I was having the same issue using the python 2.7. Follow the below steps to upgrade successfully to 3.6.
You can also try this one-

  1. See before upgrading version is 2.x

    python --version
    Python 2.7.5
    
  2. Use below command to upgrade your python to 3.x version-

    yum install python3x

    replace x with the version number you want.

    i.e. for installing python 3.6 execute

    yum install python36
    
  3. After that if you want to set this python for your default version then in bashrc file add

    vi ~/.bashrc

    alias python='python3.6'
    
  4. execute bash command to apply the settings

    bash 
    
  5. Now you can see the version below

    python --version
    Python 3.6.3
    
ぃ弥猫深巷。 2024-12-22 00:37:32

以下是我安装 Python3 的步骤:

yum install wget
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz  
sudo tar xvf Python-3.*   
cd Python-3.* 
sudo ./configure --prefix=/opt/python3    
sudo make   
sudo make install   
sudo ln -s /opt/python3/bin/python3 /usr/bin/python3

$ /usr/bin/python3    
Python 3.6.0

Here are the steps i followed to install Python3:

yum install wget
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz  
sudo tar xvf Python-3.*   
cd Python-3.* 
sudo ./configure --prefix=/opt/python3    
sudo make   
sudo make install   
sudo ln -s /opt/python3/bin/python3 /usr/bin/python3

$ /usr/bin/python3    
Python 3.6.0
娇俏 2024-12-22 00:37:32

Software Collections 使用 Python 3.5 的三个步骤:

sudo yum install centos-release-scl
sudo yum install rh-python35
scl enable rh-python35 bash

请注意 sudo 是最后一个命令不需要。现在我们可以看到 python 3 是当前 shell 的默认设置:

python --version
Python 3.5.1

如果您希望将 Python 2 作为当前 shell 的默认设置,只需跳过最后一个命令即可。

现在,假设您的 Python 3 脚本给出了类似 /usr/bin/env: python3: No such file or directory 的错误。这是因为安装通常是在不寻常的路径上进行的:

/opt/rh/rh-python35/root/bin/python3

上面的路径通常是符号链接。如果您希望在启动时将 python3 自动添加到所有用户的 $PATH 中,一种方法是添加如下文件:

sudo vim /etc/profile.d/rh-python35.sh

包含以下内容:

#!/bin/bash

PATH=$PATH:/opt/rh/rh-python35/root/bin/

其中 现在重新启动后,如果我们这样做

python3 --version

它应该可以正常工作。一个例外是 Jenkins 服务器中自动生成的用户,例如“jenkins”,它没有 shell。在这种情况下,在脚本中手动添加 $PATH 的路径是一种方法。

最后,如果您使用 sudo pip3 安装软件包,但它告诉您无法找到 pip3,则可能是您有 secure_path em> 在 /etc/sudoers 中。使用 sudo visudo 检查应该可以确认这一点。要在运行命令时临时使用标准PATH,您可以执行以下操作,例如:

sudo env "PATH=$PATH" pip3 --version

请参阅这个问题了解更多详细信息。

注意:Software Collections 有一个较新的 Python 3.6,但我现在不推荐它,因为我在尝试安装 Pycurl 时遇到了很大的麻烦。对于 Python 3.5,这不是问题,因为我刚刚执行了 sudo yum install sclo-python35-python-pycurl ,它开箱即用。

Three steps using Python 3.5 by Software Collections:

sudo yum install centos-release-scl
sudo yum install rh-python35
scl enable rh-python35 bash

Note that sudo is not needed for the last command. Now we can see that python 3 is the default for the current shell:

python --version
Python 3.5.1

Simply skip the last command if you'd rather have Python 2 as the default for the current shell.

Now let's say that your Python 3 scripts give you an error like /usr/bin/env: python3: No such file or directory. That's because the installation is usually done to an unusual path:

/opt/rh/rh-python35/root/bin/python3

The above would normally be a symlink. If you want python3 to be automatically added to the $PATH for all users on startup, one way to do this is adding a file like:

sudo vim /etc/profile.d/rh-python35.sh

Which would have something like:

#!/bin/bash

PATH=$PATH:/opt/rh/rh-python35/root/bin/

And now after a reboot, if we do

python3 --version

It should just work. One exception would be an auto-generated user like "jenkins" in a Jenkins server which doesn't have a shell. In that case, manually adding the path to $PATH in scripts would be one way to go.

Finally, if you're using sudo pip3 to install packages, but it tells you that pip3 cannot be found, it could be that you have a secure_path in /etc/sudoers. Checking with sudo visudo should confirm that. To temporarily use the standard PATH when running commands you can do, for example:

sudo env "PATH=$PATH" pip3 --version

See this question for more details.

NOTE: There is a newer Python 3.6 by Software Collections, but I wouldn't recommend it at this time, because I had major headaches trying to install Pycurl. For Python 3.5 that isn't an issue because I just did sudo yum install sclo-python35-python-pycurl which worked out of the box.

暖树树初阳… 2024-12-22 00:37:32

如果您需要官方 RHEL 软件包,可以使用 RHSCL(红帽软件集合)

更多详细信息:

您必须有权访问红帽客户门户才能阅读完整文章。

If you want official RHEL packages you can use RHSCL (Red Hat Software Collections)

More details:

You have to have access to Red Hat Customer Portal to read full articles.

内心旳酸楚 2024-12-22 00:37:32

如果您安装了 epel-releaseyum install python34.x86_64 就可以工作,这个答案解释了如何操作,并且我确认它在RHEL 7.3上有效

$ cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.3 (Maipo)

$ type python3
python3 is hashed (/usr/bin/python3)

yum install python34.x86_64 works if you have epel-release installed, which this answer explains how to, and I confirmed it worked on RHEL 7.3

$ cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.3 (Maipo)

$ type python3
python3 is hashed (/usr/bin/python3)
想你的星星会说话 2024-12-22 00:37:32

对于 Amazon Linux 上的 RHEL,使用 python3 我必须这样做:

sudo yum 安装 python34-devel

For RHEL on Amazon Linux, using python3 I had to do :

sudo yum install python34-devel

猫瑾少女 2024-12-22 00:37:32

当SCL不可用时完全工作36(基于Joys输入)

yum install wget –y
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm –ivh epel-*.rpm
yum install python36

sudo yum install python34-setuptools
sudo mkdir /usr/local/lib/python3.6
sudo mkdir /usr/local/lib/python3.6/site-packages

sudo easy_install-3.6 pip

最后激活环境......

pyvenv-3.6 py3
source py3/bin/activate

然后python3

Full working 36 when SCL is not available (based on Joys input)

yum install wget –y
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm –ivh epel-*.rpm
yum install python36

sudo yum install python34-setuptools
sudo mkdir /usr/local/lib/python3.6
sudo mkdir /usr/local/lib/python3.6/site-packages

sudo easy_install-3.6 pip

Finally activate the environment...

pyvenv-3.6 py3
source py3/bin/activate

Then python3

撩人痒 2024-12-22 00:37:32

您可以安装 miniconda (https://conda.io/miniconda.html)。这比 python 3.7 稍微多一点,但安装非常直接和简单。

curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O
sudo yum install bzip2
bash Miniconda3-latest-Linux-x86_64.sh

您必须接受许可协议并在交互模式下选择一些选项(接受默认值)。
我相信它也可以以某种方式静默安装。

You can install miniconda (https://conda.io/miniconda.html). That's a bit more than just python 3.7 but the installation is very straightforward and simple.

curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O
sudo yum install bzip2
bash Miniconda3-latest-Linux-x86_64.sh

You'll have to accept the license agreement and choose some options in interactive mode (accept the defaults).
I believe it can be also installed silently somehow.

野の 2024-12-22 00:37:32

对于使用 AWS EC2 RHEL 7.5 的用户,(使用 sudo)启用所需的存储库

yum-config-manager --enable rhui-REGION-rhel-server-optional
yum-config-manager --enable rhui-REGION-rhel-server-rhscl

安装 Python 3.6

yum install rh-python36

安装其他依赖项

yum install rh-python36-numpy  rh-python36-scipy  rh-python36-python-tools  rh-python36-python-six

For those working on AWS EC2 RHEL 7.5, (use sudo) enable required repos

yum-config-manager --enable rhui-REGION-rhel-server-optional
yum-config-manager --enable rhui-REGION-rhel-server-rhscl

Install Python 3.6

yum install rh-python36

Install other dependencies

yum install rh-python36-numpy  rh-python36-scipy  rh-python36-python-tools  rh-python36-python-six
久伴你 2024-12-22 00:37:32

从 RHEL 8 开始,您可以直接从官方存储库安装 python3:

$ podman run --rm -ti ubi8 bash
[root@453fc5c55104 /]# yum install python3                                                                                                                                                    
Updating Subscription Management repositories.                                                                                                                                                
Unable to read consumer identity                                                                                                                                                              
Subscription Manager is operating in container mode.                                                                                                                                          
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  

...

Installed:
  platform-python-pip-9.0.3-16.el8.noarch
  python3-pip-9.0.3-16.el8.noarch
  python3-setuptools-39.2.0-5.el8.noarch
  python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64      

Complete!

您甚至可以获得 python 3.8:

[root@453fc5c55104 /]# yum install python38
Installed:
  python38-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64
  python38-libs-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64                                       
  python38-pip-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch                                  
  python38-pip-wheel-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch                                 
  python38-setuptools-41.6.0-4.module+el8.2.0+5978+503155c0.noarch                           
  python38-setuptools-wheel-41.6.0-4.module+el8.2.0+5978+503155c0.noarch                          

Complete!

As of RHEL 8, you can install python3 directly from the official repositories:

$ podman run --rm -ti ubi8 bash
[root@453fc5c55104 /]# yum install python3                                                                                                                                                    
Updating Subscription Management repositories.                                                                                                                                                
Unable to read consumer identity                                                                                                                                                              
Subscription Manager is operating in container mode.                                                                                                                                          
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  

...

Installed:
  platform-python-pip-9.0.3-16.el8.noarch
  python3-pip-9.0.3-16.el8.noarch
  python3-setuptools-39.2.0-5.el8.noarch
  python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64      

Complete!

You can even get python 3.8:

[root@453fc5c55104 /]# yum install python38
Installed:
  python38-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64
  python38-libs-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64                                       
  python38-pip-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch                                  
  python38-pip-wheel-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch                                 
  python38-setuptools-41.6.0-4.module+el8.2.0+5978+503155c0.noarch                           
  python38-setuptools-wheel-41.6.0-4.module+el8.2.0+5978+503155c0.noarch                          

Complete!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文