我正在尝试按照以下步骤在RHEL上安装Python3:
yum search python3
No matches found for: python3
的意思是没有找到与 "python3" 相关的匹配项。yum search python
搜索结果中没有包含python3的内容。我接下来应该尝试什么?
我正在尝试按照以下步骤在RHEL上安装Python3:
yum search python3
No matches found for: python3
的意思是没有找到与 "python3" 相关的匹配项。yum search python
搜索结果中没有包含python3的内容。我接下来应该尝试什么?
从RPM安装通常更好,因为:
Red Hat通过EPEL存储库添加了以下内容:
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
在CentOS 7中,pip3.6
已经作为一个软件包提供了 :)
sudo yum install -y epel-release
sudo yum install -y python36 python36-pip
您可以使用pyvenv
创建您的虚拟环境:
python3.6 -m venv /tmp/foo
如果您使用 pyvenv
脚本,将会收到一个警告:
$ pyvenv-3.6 /tmp/foo
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv`
IUS社区提供了一些适用于RHEL和CentOS的最新软件包。背后的人来自Rackspace,我认为他们非常值得信赖...
在这里选择适合您的正确存储库:
sudo yum install -y https://repo.ius.io/ius-release-el6.rpm
sudo yum install -y python36u python36u-pip
您可以使用 pyvenv
创建您的虚拟环境:
python3.6 -m venv /tmp/foo
sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-pip
您可以使用pyvenv
创建您的虚拟环境:
python3.6 -m venv /tmp/foo
https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/iu<200c><200b>s-release-1.0-14.ius.centos6.noarch.rpm
这是Unicode字符:
http://www.fileformat.info/info/unicode/char/200c/index.htm我的原始答案中的URL有效,我刚刚测试过。 - Samuel Phanpython34u-pip
。 - Samuel Phan手动安装Python很容易(即从源代码构建):
下载(在Python.org上可能有更新的版本):
$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
解压缩
$ tar xf Python-3.*
$ cd Python-3.*
准备编译
$ ./configure
构建
$ make
安装
$ make install
或者,如果您不想覆盖python
可执行文件(在某些发行版上更安全,比如RHEL6需要python
是2.x),则可以通过 altinstall
安装python3.*
作为系统默认的并发实例:
$ make altinstall
如果你想要安装到另一个目录,可以在configure
命令中添加参数--prefix
。
例如:如果要将Python“安装”到/opt/local中,则只需添加--prefix=/opt/local
。
在make install
步骤之后:为了使用新的Python安装,可能需要将[prefix]/bin添加到$PATH
和[prefix]/lib添加到$LD_LIBRARY_PATH
(取决于你传递的--prefix
参数)。
./configure --with-ensurepip=install
可启用pip3
,否则编译后将无法安装pip3
。 - Searene除了gecco的回答外,我建议将第3步修改为:
./configure
to:
./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
/opt
目录?事实上,/usr/local
目录就是专门用来存放此类软件的,默认情况下,如果在运行 ./configure
时没有显式指定 --prefix
,那么安装程序会把软件安装到 /usr/local
目录下。 - cababungaexport PATH=$PATH:/opt/python3/bin
。 - Caleb现在,Red Hat软件集合中包括Python 3.4版本,除了Python 2.7和3.3。这些都适用于RHEL 6和7。
RHSCL 2.0文档在https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/
还有很多文章可以在developerblog.redhat.com上找到。
<opinion>
使用SCL yum仓库可能比其他yum仓库更好,因为这些RPM是由Redhat开发/测试的(即第一方RPM而不是第三方)。</opinion>
编辑
# 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
rhel
和centos
的7个版本都已经升级到了python 3.6。scl enable rh-python34 bash
?这对以后使用有什么影响吗? - Nathan Basanesesudo 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
scl enable python33 bash
启动一个新的 shell,该 shell 将启用 Python 3;要么使用scl enable python33 'python hello.py'
在当前 shell 中运行你的 Python 文件并使用 Python 3。 - stratagemsubscription-manager repos --enable rhel-7-server-optional-rpms --enable rhel-server-rhscl-7-rpms
。然后您可以运行 yum install rh-python36
命令进行安装。更多信息请参见如何在RHEL上安装Python 3。 - Rob T.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
更多信息请参见在RHEL上安装Python 3、pip、venv、virtualenv和pipenv,网址为developers.redhat.com。该文档涵盖了从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。我看到所有的回答要么是要求从源代码编译python3,要么是安装二进制RPM包。这里提供另一个答案,以启用EPEL(企业版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
另请参见链接
sudo yum install python34-setuptools
- OSP我曾经使用Python 2.7遇到过同样的问题。按以下步骤成功升级到3.6。 您还可以尝试以下方法-
See before upgrading version is 2.x
python --version
Python 2.7.5
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
After that if you want to set this python for your default version then in bashrc file add
vi ~/.bashrc
alias python='python3.6'
execute bash command to apply the settings
bash
Now you can see the version below
python --version
Python 3.6.3
rh-python36
。 - Rob T.