2010-11-10 18 views
59

Qualcuno può fornire i passaggi necessari per installare python versione 2.7 su SUSE e RedHat? La versione che è lì è come 2.4 e ho bisogno di averlo almeno 2.6 per far funzionare il mio script. Quindi dopo l'installazione, posso digitare Python in un xTerm e ottenere l'interfaccia della riga di comando di Python 2.7.Su Linux SUSE o RedHat, come carico Python 2.7

+0

"RedHat"? Intendi Red Hat Enterprise Linux? Quale versione? –

+0

5.4 e 4 sono quelli – Dag

+0

11 e 10 su SuSE – Dag

risposta

121

Istruzioni per scaricare sorgente e installare:

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

NOTA: è necessario verificare l'ultima versione di python 2.7.x, poiché viene aggiornata frequentemente. Attualmente (ottobre 2017), l'ultima versione è la 2.7.14, anche se questo commento otterrà versioni vecchie e nuove probabilmente saranno rilasciate ogni 6 mesi circa.

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 

(MODIFICA: make install -> make altinstall per il commento di Ignacio).

+0

quindi devo semplicemente digitare quei comandi in una finestra di xterm e sono pronto a partire? – Dag

+9

+1 per mostrare i comandi effettivi (caro a qualsiasi persona Linux) per decomprimere e 'installare' il software dalla sorgente :) – g19fanatic

+49

'make install' danneggerà il sistema Python. Usa invece 'make altinstall'. –

1

Grande cosa su linux, sei ancora in grado di download the source e sulla maggior parte dei sistemi hai tutti gli strumenti per compilare la versione da solo.

Al fine di ottenere un cli pitone da xterm semplicemente digitando python, la directory di pitone bin deve essere nella variabile percorso di sistema (Red Hat example, Suse example)

1

Se si può vivere con 2.6, EPEL ha per RHEL 5 nel pacchetto python26, anche se sarà necessario utilizzare python2.6 per invocarlo dal momento che il sistema sarà ancora bisogno di essere python 2.4 per eseguire.

+0

quindi su RHEL devo eseguire con 2 versioni di python se voglio eseguire il mio programma che non funziona su 2.4? – Dag

+0

L'utente * deve * disporre di 2.4 in modo che il sistema funzioni nelle normali aspettative. Qualsiasi numero di versioni secondarie può essere installato in parallelo. –

+0

SO come installo in parallelo 2.7? – Dag

2

Devi lasciare Python 2.4 installato su RHEL/Centos; altrimenti, gli strumenti iniziano a rompersi. Puoi fare una doppia installazione, però; Parlo di questo qui:

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

Il post è di circa 2,6, ma vale anche per 2.7.

+1

Anche questo collegamento funzionerebbe quando si installa python su RH, lasciando Python 2.4 così com'è: http://tecadmin.net/install-python-2-7-on-centos-rhel/ –

7

La risposta accettata dalla jimbob dr (usando make altinstall) mi ha fatto la maggior parte del tragitto, con python2.7 in /usr/local/bin ma ho anche bisogno di installare alcuni moduli di terze parti. La cosa bella è che easy_install ottiene i suoi percorsi di installazione dalla versione di Python che stai usando, ma ho scoperto che ho ancora bisogno di installare easy_install per Python 2.7 altrimenti otterrei ImportError: No module named pkg_resources. Quindi ho fatto questo:

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 

Ora ho easy_install e easy_install-2.7 in// local/bin usr e la versione del easy_install 2.6 L'ex override del mio sistema, quindi ho rimosso:

sudo rm /usr/local/bin/easy_install 

Ora può installare le librerie per la versione 2.7 di Python come questo:

sudo /usr/local/bin/easy_install-2.7 numpy 
+4

Ho dovuto fare 'yum -y install zlib-devel' per poter installare setuptools. – par

12

RHEL 6.2 usando (aveva Python 2.6, ho bisogno di Python 2.7.3) Quindi:

$ 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. 

EDIT:

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 
+1

Cosa significa 'scl'? Questo stabile è stabile? Come EPEL, promette di non interferire con i pacchetti di sistema predefiniti? –

+5

@StefanLasiewski: 'scl' sta per [Software Collections] (https://fedorahosted.org/SoftwareCollections/), e sì lo fanno esplicitamente (è in realtà il loro vero scopo). [Introduzione] (http://developerblog.redhat.com/2013/01/28/software-collections-on-red-hat-enterprise-linux/). [Guida] (https://docs.fedoraproject.org/en-US/Fedora_Contributor_Documentation/1/html-single/Software_Collections_Guide/index.html). Il repository suggerito da YumYumYum è gestito da un [Red Hat engineer] (https://fedoraproject.org/w/index.php?title=User:Bkabrda&oldid=318815) e si rivolge a RHEL6. – tne

2

Eseguire il seguito comandi per rendere il lavoro yum così come 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 
+0

usando altinstall lo installa su '/ usr/local' di design. l'altro modo sarebbe usare './configure --prefix =/usr/local', quindi basta installare. il sistema python rimarrà intatto in entrambi i casi. – erm3nda

0

Se avete bisogno di pip e strumento di installazione, installare openssl e opessl-devl prima di creare python2.7

yum install openssl-devel 

Poi seguire https://stackoverflow.com/a/4149444/429476

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

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

poi per installare pip

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

poi per installare altri pacchetti pip2.7 installare nome_pacchetto

0

Se si desidera installare Python 2.7 su Oracle Linux, è possibile procedere come segue:

Abilitare la raccolta software in /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 

Dopo aver apportato questa modifica al repository yum si può semplicemente eseguire il comando yum per installare il Python:

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

modificare bash_profile con le variabili seguire:

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 

Ora è possibile utilizzare python2.7 e pip per installare i moduli Python:

/opt/rh/python27/root/usr/bin/pip install pynacl 
/opt/rh/python27/root/usr/bin/python2.7 --version