web-dev-qa-db-fra.com

Sous Linux SUSE ou RedHat, comment charger Python 2.7

Quelqu'un peut-il fournir les étapes nécessaires à l'installation de Python version 2.7 sur SUSE et RedHat? La version disponible est du type 2.4 et il me faut au moins la version 2.6 pour que mon script fonctionne . Après l’installation, je peux saisir Python dans un xTerm et obtenir l’interface de ligne de commande Python 2.7.

59
Dag

Instructions pour télécharger la source et installer:

https://www.python.org/download/

REMARQUE: vous devez rechercher la dernière version de python 2.7.x, car elle est mise à jour fréquemment. Actuellement (octobre 2017), la dernière version est la 2.7.14, bien que ce commentaire soit ancien et que les nouvelles versions soient publiées tous les six mois environ.

wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz # Download
tar xvfz Python-2.7.14.tgz # unzip
cd Python-2.7.14 # go into directory
./configure
make # build
su # or 'Sudo su' if there is no root user
make altinstall

(EDIT: make install -> make altinstall selon le commentaire de Ignacio).

127
dr jimbob

RHEL 6.2 using (avait Python 2.6, j'ai besoin de Python 2.7.3 ) Donc:

$ Sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python27.repo >> /etc/yum.repos.d/scl.repo'

$ yum search python27
Loaded plugins: Amazon-id, rhui-lb, security
scl_python27                                                                                                                                      | 2.9 kB     00:00     
scl_python27/primary_db                                                                                                                           |  38 kB     00:00     
========================================================================= N/S Matched: python27 =========================================================================
python27.i686 : Package that installs python27
python27.x86_64 : Package that installs python27
python27-expat-debuginfo.i686 : Debug information for package python27-expat
python27-expat-debuginfo.x86_64 : Debug information for package python27-expat
python27-python-coverage-debuginfo.i686 : Debug information for package python27-python-coverage
python27-python-coverage-debuginfo.x86_64 : Debug information for package python27-python-coverage
python27-python-debuginfo.i686 : Debug information for package python27-python
python27-python-debuginfo.x86_64 : Debug information for package python27-python
python27-python-markupsafe-debuginfo.i686 : Debug information for package python27-python-markupsafe
python27-python-markupsafe-debuginfo.x86_64 : Debug information for package python27-python-markupsafe
python27-python-simplejson-debuginfo.i686 : Debug information for package python27-python-simplejson
python27-python-simplejson-debuginfo.x86_64 : Debug information for package python27-python-simplejson
python27-python-sqlalchemy-debuginfo.i686 : Debug information for package python27-python-sqlalchemy
python27-python-sqlalchemy-debuginfo.x86_64 : Debug information for package python27-python-sqlalchemy
python27-runtime.i686 : Package that handles python27 Software Collection.
python27-runtime.x86_64 : Package that handles python27 Software Collection.
python27-babel.noarch : Tools for internationalizing Python applications
python27-build.i686 : Package shipping basic build configuration
python27-build.x86_64 : Package shipping basic build configuration
python27-expat.i686 : An XML parser library
python27-expat.x86_64 : An XML parser library
python27-expat-devel.i686 : Libraries and header files to develop applications using expat
python27-expat-devel.x86_64 : Libraries and header files to develop applications using expat
python27-expat-static.i686 : expat XML parser static library
python27-expat-static.x86_64 : expat XML parser static library
python27-python.i686 : An interpreted, interactive, object-oriented programming language
python27-python.x86_64 : An interpreted, interactive, object-oriented programming language
python27-python-babel.noarch : Library for internationalizing Python applications
python27-python-coverage.i686 : Code coverage testing module for Python
python27-python-coverage.x86_64 : Code coverage testing module for Python
python27-python-debug.i686 : Debug version of the Python runtime
python27-python-debug.x86_64 : Debug version of the Python runtime
python27-python-devel.i686 : The libraries and header files needed for Python development
python27-python-devel.x86_64 : The libraries and header files needed for Python development
python27-python-docutils.noarch : System for processing plaintext documentation
python27-python-jinja2.noarch : General purpose template engine
python27-python-libs.i686 : Runtime libraries for Python
python27-python-libs.x86_64 : Runtime libraries for Python
python27-python-markupsafe.i686 : Implements a XML/HTML/XHTML Markup safe string for Python
python27-python-markupsafe.x86_64 : Implements a XML/HTML/XHTML Markup safe string for Python
python27-python-nose.noarch : Discovery-based unittest extension for Python
python27-python-nose-docs.noarch : Nose Documentation
python27-python-pygments.noarch : Syntax highlighting engine written in Python
python27-python-setuptools.noarch : Easily build and distribute Python packages
python27-python-simplejson.i686 : Simple, fast, extensible JSON encoder/decoder for Python
python27-python-simplejson.x86_64 : Simple, fast, extensible JSON encoder/decoder for Python
python27-python-sphinx.noarch : Python documentation generator
python27-python-sphinx-doc.noarch : Documentation for python-sphinx
python27-python-sqlalchemy.i686 : Modular and flexible ORM library for python
python27-python-sqlalchemy.x86_64 : Modular and flexible ORM library for python
python27-python-test.i686 : The test modules from the main python package
python27-python-test.x86_64 : The test modules from the main python package
python27-python-tools.i686 : A collection of development tools included with Python
python27-python-tools.x86_64 : A collection of development tools included with Python
python27-python-virtualenv.noarch : Tool to create isolated Python environments
python27-python-werkzeug.noarch : The Swiss Army knife of Python web development
python27-python-werkzeug-doc.noarch : Documentation for python-werkzeug
python27-tkinter.i686 : A graphical user interface for the Python scripting language
python27-tkinter.x86_64 : A graphical user interface for the Python scripting language

  Name and summary matches only, use "search all" for everything.

MODIFIER:

CentOS 6.x: http://dev.centos.org/centos/6/SCL/x86_64/python27/

$ Sudo sh -c 'wget -qO- http://dev.centos.org/centos/6/SCL/scl.repo >> /etc/yum.repos.d/scl.repo'
$ scl enable python27 'python --version'
python 2.7.5
$ scl enable python27 bash
$ python --version
Python 2.7.5
12
YumYumYum

La réponse acceptée de dr jimbob (avec make altinstall) m'a permis de trouver le chemin le plus complet, avec python2.7 dans /usr/local/bin, mais j'avais également besoin d'installer des modules tiers. Ce qui est bien, c’est que easy_install tire ses emplacements d’installation de la version de Python que vous utilisez, mais j’ai trouvé que j’avais encore besoin d’installer easy_install pour Python 2.7, sinon j’obtiendrais ImportError: No module named pkg_resources. Alors j'ai fait ça:

wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.Egg
Sudo -i
export PATH=$PATH:/usr/local/bin
sh setuptools-0.6c11-py2.7.Egg
exit

Maintenant, j'ai easy_install et easy_install-2.7 dans/usr/local/bin et l'ancien remplace la version 2.6 d'easy_install de mon système, je l'ai donc supprimée:

Sudo rm /usr/local/bin/easy_install

Maintenant, je peux installer les bibliothèques pour la version 2.7 de Python comme ceci:

Sudo /usr/local/bin/easy_install-2.7 numpy
7
Rob Fisher

Pour installer Python 2.7.2, utilisez ce script - https://github.com/bngsudheer/bangadmin/blob/master/linux/centos/6/x86_64/build-python-27.sh

Il vous permet également d’obtenir une assistance sqlite et readline.

3
Sudheer

Exécutez les commandes ci-dessous pour faire fonctionner yum ainsi que python2.7

yum groupinstall -y development
yum groupinstall -y 'development tools'
yum install -y zlib-dev openssl-devel wget sqlite-devel bzip2-devel
yum -y install gcc gcc-c++ numpy python-devel scipy git boost*
yum install -y *lapack*
yum install -y gcc gcc-c++ make bison flex autoconf libtool memcached libevent libevent-devel uuidd libuuid-devel  boost boost-devel libcurl-dev libcurl curl gperf mysql-devel

cd
mkdir srk
cd srk 
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
yum install xz-libs
xz -d Python-2.7.6.tar.xz
tar -xvf Python-2.7.6.tar
cd Python-2.7.6
./configure --prefix=/usr/local
make
make altinstall



echo "export PATH="/usr/local/bin:$PATH"" >> /etc/profile
source /etc/profile
mv /usr/bin/python /usr/bin/python.bak
update-alternatives --install /usr/bin/python python /usr/bin/python2.6 1
update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 2
update-alternatives --config python
sed -i "s/python/python2.6/g" /usr/bin/yum
2
Shahrukh Khan

Vous devez laisser Python 2.4 installé sur RHEL/Centos; sinon, les outils commencent à casser. Vous pouvez faire une double installation, cependant; J'en parle ici:

http://thebuild.com/blog/2009/10/17/wordpress-to-djangopostgresql-part-3-installing-Apache-python-2-6-psycopg2-and-mod_wsgi/

Le message est d'environ 2,6, mais s'applique également à 2,7.

2
Christophe

Ce qui est bien avec Linux, vous pouvez toujours télécharger le code source et, sur la plupart des systèmes, vous disposez de tous les outils pour compiler vous-même la version.

Pour obtenir une clé python de xterm simplement en tapant python, le répertoire bin de python doit figurer dans la variable de chemin d'accès système ( exemple Red Hat , exemple Suse ).

1
g19fanatic

Si vous pouvez vivre avec 2.6, EPEL l’a pour RHEL 5 dans le package python26, bien que vous deviez utiliser python2.6 pour l’appeler, car le système aura toujours besoin de python pour être 2.4.

1

Si vous obtenez une erreur lors de l'étape ./configure,

configure: error: dans `/home//Downloads/Python-2.7.14': configure: erreur: pas de compilateur C acceptable trouvé dans $ PATH

alors essayez ceci.

aucun compilateur C acceptable trouvé dans $ PATH lors de l'installation de python

0
MonkeyMagic

Si vous avez besoin de pip et d’un outil de configuration, veuillez installer openssl et opessl-devl avant de créer python2.7.

 yum install openssl-devel

Ensuite, suivez https://stackoverflow.com/a/4149444/429476

Alors https://pypi.python.org/pypi/setuptools

wget https://bootstrap.pypa.io/ez_setup.py
python2.7 ez_setup.py

Puis installer pip

wget https://bootstrap.pypa.io/get-pip.py
python2.7 get-pip.py

Ensuite, pour installer d'autres paquets, installer pip2.7

0
Alex Punnen

Si vous souhaitez installer Python 2.7 sur Oracle Linux, procédez comme suit:

Activez la collection de logiciels dans /etc/yum.repos.d/public-yum-ol6.repo.

vim /etc/yum.repos.d/public-yum-ol6.repo

[public_ol6_software_collections] 
name=Software Collection Library release 1.2 packages for Oracle Linux 6 
(x86_64) 
baseurl=[http://yum.Oracle.com/repo/OracleLinux/OL6/SoftwareCollections12/x86_64/][1] 
    gpgkey=file:[///etc/pki/rpm-gpg/RPM-GPG-KEY-Oracle][2] 
    gpgcheck=1 
    enabled=1 <==============change from 0 to 1

Après avoir apporté cette modification au référentiel yum, vous pouvez simplement exécuter la commande yum pour installer Python:

yum install gcc libffi libffi-devel python27 python27-python-devel openssl-devel python27-MySQL-python

éditer bash_profile avec les variables suivantes:

vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/opt/rh/python27/root/usr/bin export PATH
LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64 export LD_LIBRARY_PATH
PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig export PKG_CONFIG_PATH

Vous pouvez maintenant utiliser python2.7 et pip pour installer les modules Python:

/opt/rh/python27/root/usr/bin/pip install pynacl
/opt/rh/python27/root/usr/bin/python2.7 --version
0
Adriano R P L