Aktualisieren Sie Python auf Centos 6.5 von 2.6 auf 2.7

Ich möchte meine Python-Version auf dem Server aktualisieren, meine aktuelle Python-Version ist 2.6 und ich möchte sie auf 2.7 aktualisieren. Plesk ist auf unserem Server installiert und ich habe auch Zugriff auf ssh.

Wie kann ich es in Centos 6.5 aktualisieren?

Ich versuche unten

Python herunterladen und extrahieren

wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz  
xz -d Python-2.7.8.tar.xz  
tar -xvf Python-2.7.8.tar  

Installationsprozess

# Enter the directory:
cd Python-2.7.8

# Run the configure:
./configure --prefix=/usr/local

# compile and install it:
make  
make altinstall
# Checking Python version:
[root@nicetry ~]# python2.7 -V
Python 2.7.8  
export PATH="/usr/local/bin:$PATH"  

Aber wenn ich python --version tippe, gibt es 2.6.6

Author: Greenonline, 2016-01-17

5 answers

Ich kann noch keinen Kommentar hinzufügen, nur antworten: Centos setzt für yum auf Python 2.6. Sie können Ihr System und yum brechen, wenn Sie global zu 2.7 wechseln.

 8
Author: Jaur,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2016-01-17 12:55:42

Fügen Sie die folgende Zeile in die Datei ~/.bashrc ein:

alias python=/usr/local/bin/python2.7

Führen Sie nun den Befehl aus:

source ~/.bashrc

Geben Sie nun python ein, um zu überprüfen, welcher Version sie zugeordnet ist. Es ist Python2.7 zugeordnet.

 9
Author: Nandakishore,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2016-04-19 23:26:41

Folgen Sie diesem link: https://ruter.github.io/2015/12/03/Update-python/ Ich habe getan, was es sagt und Python wurde erfolgreich aktualisiert. Wenn Sie Fehler treffen:

ImportError: cannot import name HTTPSHandler

Einfach openssl installieren:

yum install openssl openssl-devel -y

ÜBRIGENS, centos verwendet yum, und yum verwendet 2.6 python, wenn Sie dem Link folgen, würden Sie python2.6 nach /usr/bin/python2. 6 verschoben haben, also in:

vim `which yum`

Ändern Sie #!/usr/bin/python in #!/usr/bin/python2.6

 0
Author: Tiina,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2016-09-08 04:44:59

Sie können /usr/bin/python nicht ändern, ohne Ihren Server zu beschädigen. Verwenden Sie einfach die, die Sie auf /usr/local/bin/python2.7 installiert haben, oder wechseln Sie zu IUS - Paketen für python27 (die auf /usr/bin/python2.7 installiert werden. In jedem Fall müssen Sie /usr/bin/python in Ruhe lassen.

 -1
Author: carlwgeorge,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2016-02-24 03:09:10

Es könnte sein, dass Python 2.7 installiert wurde, aber Sie sollten python2.7 für die Verwendung dieser Version verwenden. Überprüfen Sie python2.7 --version

 -1
Author: Abhiram Pappula,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/techietown.info/template/agent.layouts/content.php on line 61
2017-02-10 10:25:52