RHEL에 Python 3 설치
다음 단계를 사용하여 RHEL에 python3을 설치하려고합니다.
yum search python3
어느 것이 반환 No matches found for: python3
뒤에 :
yum search python
검색 결과에 python3이 포함되어 있지 않습니다. 다음에 무엇을 시도해야합니까?
수동으로 설치하기 쉽습니다.
다운로드 ( 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
실행 (안전을 일부 배포판의에 대한 최소한yum
의 요구python
등 RHEL6에 대한 같은 2.X를, 수) - 당신은 설치할 수 있습니다python3.*
와 시스템 기본에 동시 인스턴스로altinstall
:$ make altinstall
대체 설치 디렉토리 --prefix
가 필요한 경우 configure
명령에 전달할 수 있습니다 .
예 : / opt / local에 Python을 '설치'하려면 add를 추가하십시오 --prefix=/opt/local
.
make install
단계 후 : 새로운 Python 설치를 사용하려면 여전히 [접두사] / bin을 $PATH
및 [접두사] / lib를 $LD_LIBRARY_PATH
( --prefix
전달한 사용자 에 따라) 추가해야 할 수 있습니다.
일반적으로 RPM에서 설치하는 것이 좋습니다.
- python3을 올바르게 설치하고 제거 할 수 있습니다 .
- 설치 시간이 빠른 방법입니다 . 여러 VM이있는 클라우드 환경에서 작업하는 경우 각 VM에서 python3을 컴파일 할 수 없습니다.
해결 방법 1 : Red Hat & EPEL 리포지토리
Red Hat은 EPEL 저장소를 통해 추가되었습니다 :
- CentOS 6 용 Python 3.4
- CentOS 7 용 Python 3.6
[EPEL] CentOS 6에 Python 3.4를 설치하는 방법
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
다음을 사용하여 virtualenv 를 만들 수 있습니다 pyvenv
.
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
다음을 사용하여 virtualenv 를 만들 수 있습니다 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`
해결 방법 2 : IUS 커뮤니티 리포지토리
IUS Community는 RHEL & CentOS를위한 최신 패키지를 제공합니다 . 뒤에있는 사람들은 Rackspace에서 왔으므로 신뢰할 수 있다고 생각합니다 ...
여기에서 적합한 리포지토리를 확인하십시오.
https://ius.io/GettingStarted/
[IUS] CentOS 6에 Python 3.6을 설치하는 방법
sudo yum install -y https://centos6.iuscommunity.org/ius-release.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://centos7.iuscommunity.org/ius-release.rpm
sudo yum install -y python36u python36u-pip
다음을 사용하여 virtualenv 를 만들 수 있습니다 pyvenv
.
python3.6 -m venv /tmp/foo
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
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을 사용할 때마다 실행해야합니다.)
Python 2.7 및 3.3과 함께 Red Hat Software Collections에는 이제 Python 3.4가 포함되어 있으며 RHEL 6 및 7 모두에서 작동합니다.
RHSCL 2.0 문서는 https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/에 있습니다.
developerblog.redhat.com에 많은 기사가 있습니다.
편집하다
다음 지침 에 따라 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
RHEL6 / CentOS6 용 소스 RPM 및 이진 RPM을 여기 에서 다운로드 할 수 있습니다.
최신 Fedora 개발 소스 rpm에서 RHEL6 / CentOS6으로의 백 포트입니다.
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
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-11.noarch.rpm
rpm –ivh epel-*.rpm
yum install python36
Also see link
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-
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
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.
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.
If you want official RHEL packages you can use RHSCL (Red Hat Software Collections)
More details:
- Guide to Python 3.3 in RHSCL 1.1
- How to access and download Red Hat Software Collections (RHSCL) and/or Red Hat Developer Toolset (DTS)?
You have to have access to Red Hat Customer Portal to read full articles.
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
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)
For RHEL on Amazon Linux, using python3 I had to do :
sudo yum install python34-devel
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
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.
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
참고URL : https://stackoverflow.com/questions/8087184/installing-python-3-on-rhel
'programing tip' 카테고리의 다른 글
하위 도메인과 함께 postman을 사용할 때 "응답을 얻을 수 없습니다"응답 (0) | 2020.07.22 |
---|---|
Brew 설치 도커에 도커 엔진이 포함되어 있지 않습니까? (0) | 2020.07.22 |
앱에서 화면을 유지하려면 어떻게합니까? (0) | 2020.07.22 |
JavaScript를 사용하여 HTML에서 textArea에 maxlength를 적용하는 방법 (0) | 2020.07.21 |
플래그 열거 형이 일반적으로 16 진 값으로 정의되는 이유 (0) | 2020.07.21 |