Instalación de Python 3 en RHEL
Estoy intentando instalar python3 en RHEL siguiendo los siguientes pasos:
yum search python3
Que devolvió No matches found for: python3
Seguido de:
yum search python
Ninguno de los resultados de búsqueda contenía python3. ¿Qué debo probar ahora?
16 answers
Es fácil de instalar manualmente:
-
Descargar (puede haber nuevas versiones en Python.org):
$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
-
Descomprimir
$ tar xf Python-3.* $ cd Python-3.*
-
Preparar la compilación
$ ./configure
-
Construir
$ make
-
Instalar
$ make install
O si no desea sobrescribir el ejecutable
python
(más seguro, al menos en algunas distribucionesyum
necesitapython
ser 2.x, como para RHEL6) - puede instalarpython3.*
como un concurrent instance to the system default with analtinstall
:$ make altinstall
Ahora, si desea un directorio de instalación alternativo, puede pasar --prefix
al comando configure
.
Ejemplo: para 'instalar' Python en /opt/local, simplemente agregue --prefix=/opt/local
.
Después del paso make install
: Para usar su nueva instalación de Python, podría ser que aún tenga que agregar el [prefijo] / bin al $PATH
y [prefijo]/lib al $LD_LIBRARY_PATH
(dependiendo del --prefix
que haya pasado)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-29 07:52:31
Instalar desde RPM es generalmente mejor, porque:
- puede instalar y desinstalar (correctamente) python3.
- el tiempo de instalación de es mucho más rápido. Si trabaja en un entorno de nube con varias máquinas virtuales, no es aceptable compilar python3 en cada una de ellas.
Solución 1: Repositorios de Red Hat y EPEL
Red Hat ha añadido Python 3.4 para CentOS 6 y 7 a través del EPEL repositorio.
Desafortunadamente:
-
pip3
no está incluido en ninguna RPM. Necesita instalarlo manualmente (ver más abajo). -
pyvenv
tiene micrófonos ocultos y no funciona. Necesita usarvirtualenv
.
[EPEL] Cómo instalar Python 3.4 en CentOS 6 & 7
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
# I guess you would like to install virtualenv or virtualenvwrapper
sudo pip3 install virtualenv
sudo pip3 install virtualenvwrapper
Si desea utilizar pyvenv
, puede hacer lo siguiente para instalar pip3
en su virtualenv:
pyvenv --without-pip my_env
curl https://bootstrap.pypa.io/get-pip.py | my_env/bin/python
Pero si quieres tenerlo listo, puedes añadir esta función bash (alias) en su .bashrc
:
pyvenv() { /usr/bin/pyvenv --without-pip $@; for env in $@; do curl https://bootstrap.pypa.io/get-pip.py | "$env/bin/python"; done; }
Solución 2: Repositorios comunitarios IUS
La Comunidad IUS proporciona paquetes actualizados para RHEL & CentOS. Los chicos detrás son de Rackspace, así que creo que son bastante confiables...
Compruebe el repositorio correcto para usted aquí:
Https://ius.io/GettingStarted /
[IUS] Cómo instalar Python 3.5 en CentOS 6
sudo yum install -y https://centos6.iuscommunity.org/ius-release.rpm
sudo yum install -y python35u python35u-pip
# I guess you would like to install virtualenv or virtualenvwrapper
sudo pip3.5 install virtualenv
sudo pip3.5 install virtualenvwrapper
Nota: usted tiene pyvenv-3.5
disponible listo para usar si no desea usar virtualenv
.
[IUS] Cómo instalar Python 3.5 en CentOS 7
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install -y python35u python35u-pip
# I guess you would like to install virtualenv or virtualenvwrapper
sudo pip3.5 install virtualenv
sudo pip3.5 install virtualenvwrapper
Nota: tiene pyvenv-3.5
disponible listo para usar si no desea usar virtualenv
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-05 10:23:56
Además de la respuesta de gecco, cambiaría el paso 3 de:
./configure
A:
./configure --prefix=/opt/python3
Luego, después de la instalación, también puede:
# ln -s /opt/python3/bin/python3 /usr/bin/python3
Es para asegurarse de que la instalación no entre en conflicto con python instalado con yum.
Ver explicación que he encontrado en Internet:
Http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-07-29 11:23:05
Utilice los repositorios 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
(Este último comando tendrá que ejecutarse cada vez que desee usar python27 en lugar del predeterminado del sistema.)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-05-18 15:59:37
Puede descargar un RPMs de origen y RPMs binarios para RHEL6 / CentOS6 desde aquí
Este es un backport del nuevo desarrollo de Fedora rpm de origen a RHEL6 / CentOS6
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-29 06:38:48
Junto con Python 2.7 y 3.3, Red Hat Software Collections ahora incluye Python 3.4 - todo funciona tanto en RHEL 6 como en 7.
Los documentos de RHSCL 2.0 están en https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections /
Más muchos artículos en developerblog.redhat.com.
Editar
Siga estas instrucciones para instalar Python 3.4 en RHEL 6/7 o 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
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-24 10:19:28
Python3 fue recientemente agregado a EPEL7 como Python34.
Hay un esfuerzo en curso (actualmente) para hacer pautas de empaquetado sobre cómo empaquetar cosas para Python3 en EPEL7.
Véase https://bugzilla.redhat.com/show_bug.cgi?id=1219411
y https://lists.fedoraproject.org/pipermail/python-devel/2015-July/000721.html
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-16 07:58:23
Estaba teniendo el mismo problema usando python 2.7. Siga los pasos a continuación para actualizar correctamente a 3.6. También puede probar este -
-
Ver antes de actualizar la versión es 2.x
python --version Python 2.7.5
-
Use el siguiente comando para actualizar su python a 3.x version -
Yum instalar python3x
Reemplace x con el número de versión que desee.
Es decir, para instalar python 3.6 ejecutar
yum install python36
-
Después de eso si quieres para establecer este python para su versión predeterminada, entonces en bashrc archivo add
Vi ~/.bashrc
alias python='python3.6'
-
Ejecute el comando bash para aplicar la configuración
bash
-
Ahora puedes ver la versión a continuación
python --version Python 3.6.3
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-05 07:10:44
Si desea paquetes RHEL oficiales, puede usar RHSCL (Red Hat Software Collections)
Más detalles:
- Guía para Python 3.3 en RHSCL 1.1
- ¿Cómo acceder y descargar Red Hat Software Collections (RHSCL) y / o Red Hat Developer Toolset (DTS)?
Debe tener acceso al Portal de Clientes de Red Hat para leer los artículos completos.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-02 14:12:49
Estos son los pasos que seguí para instalar 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
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-26 08:11:00
Solo para hacer una respuesta autónoma muy breve para competir con las sugerencias de "instalar desde el origen".
El paquete no se llama python3
pero hay un paquete para cada versión de Python3.
yum install python36
Te dará Python 3.6.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-12 06:19:28
Tres pasos usando Python 3.5 por Colecciones de software :
sudo yum install centos-release-scl
sudo yum install rh-python35
scl enable rh-python35 bash
Tenga en cuenta que sudo no es necesario para el último comando. Ahora podemos ver que python 3 es el valor predeterminado para el shell actual:
python --version
Python 3.5.1
Simplemente omita el último comando si prefiere tener Python 2 como predeterminado para el shell actual.
Ahora digamos que sus scripts de Python 3 le dan un error como /usr/bin/env: python3: No such file or directory
. Eso es porque la instalación se realiza generalmente a un inusual ruta:
/opt/rh/rh-python35/root/bin/python3
Lo anterior normalmente sería un enlace simbólico. Si desea que python3
se agregue automáticamente a $PATH
para todos los usuarios al inicio, una forma de hacerlo es agregar un archivo como:
sudo vim /etc/profile.d/rh-python35.sh
Que tendría algo como:
#!/bin/bash
PATH=$PATH:/opt/rh/rh-python35/root/bin/
Y ahora después de un reinicio, si lo hacemos{[17]]}
python3 --version
Simplemente debería funcionar. Una excepción sería un usuario autogenerado como "jenkins" en un servidor Jenkins que no tiene un shell. En ese caso, agregar manualmente la ruta a $PATH
en scripts sería una manera de ir.
Finalmente, si está usando sudo pip3
para instalar paquetes, pero le dice que pip3 no se puede encontrar, podría ser que tiene un secure_path en /etc/sudoers. La comprobación con sudo visudo
debe confirmarlo. Para usar temporalmente la ruta estándar al ejecutar comandos puede hacer, por ejemplo:
sudo env "PATH=$PATH" pip3 --version
Ver esta pregunta para más detalles.
NOTA : Hay un Python más nuevo 3.6 por Colecciones de software, pero no lo recomendaría en este momento, porque tuve grandes dolores de cabeza al intentar instalar Pycurl. Para Python 3.5 eso no es un problema porque acabo de hacer sudo yum install sclo-python35-python-pycurl
que funcionó fuera de la caja.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-09 15:32:36
Si está en RHEL y desea un Python compatible con Red Hat, utilice Red Hat Software collections (RHSCL). Red Hat no admite los paquetes EPEL y IUS. También muchas de las respuestas anteriores apuntan a las colecciones de software de CentOS. Aunque puede instalarlos, no son los paquetes compatibles con Red Hat para RHEL.
Además, la respuesta más votada da malos consejos: En RHEL no quieres cambiar /usr/bin/python
, /usr/bin/python2
porque es probable que rompa yum
y otras herramientas de administración de RHEL. Toma un mira /bin/yum
, es un script de Python que comienza con #!/usr/bin/python
. Si compila Python desde el código fuente, no haga un make install
como root. Eso sobrescribirá /usr/bin/python
. Si rompe yum
puede ser difícil restaurar su sistema.
Para obtener más información, consulte Cómo instalar Python 3, pip, venv, virtualenv y pipenv en RHEL en developers.redhat.com . Cubre la instalación y el uso de Python 3 desde RHSCL, el uso de entornos virtuales Python y una serie de consejos para trabajar con software colecciones y trabajo con Python en RHEL.
En pocas palabras, para instalar Python 3.6 a través de 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
Para usar una colección de software hay que habilitarla:
scl enable rh-python36 bash
Sin embargo, si desea que Python 3 esté permanentemente habilitado, puede agregar lo siguiente a su ~/.bashrc y luego cerrar sesión y volver a entrar. Ahora Python 3 está permanentemente en tu camino.
# Add RHSCL Python 3 to my login environment
source scl_source enable rh-python36
Nota: una vez que lo hace, escribir python
ahora le da Python 3.6 en lugar de Python 2.7.
Ver el artículo anterior para todo esto y mucho más detalle.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-13 16:42:39
yum install python34.x86_64
funciona si tienes epel-release
instalado, que esta respuesta explica cómo, y me confirmó que trabajó en RHEL 7.3
$ cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.3 (Maipo)
$ type python3
python3 is hashed (/usr/bin/python3)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-13 12:36:27
Para RHEL en Amazon Linux, usando python3 tuve que hacer:
Sudo yum install python34-devel
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-10 18:02:33
Veo todas las respuestas ya sea pidiendo compilar python3 desde el código o instalando el paquete binario RPM. Aquí hay otra respuesta para habilitar EPEL (Paquetes adicionales para Enterprise Linux) y luego instalar python usando yum. Pasos para 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
Véase también enlace
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-09 14:25:31