Wer endlich mal die alten Zöpfe der Python-Entwicklung abschneiden möchte sollte seine Projekte so langsam auf Python 3.x umstellen. CentOS 7 bringt per default Python in der Version 2.7.5 mit. Wer auf eine aktuelle Version von Python wechseln möchten kann dies trotzdem ohne Probleme auch unter CentOS 7.
Dieses Tutorial zeigt wie man unter CentOS 7 Python 3.5 optional installiert. Die gezeigte Lösung kann auch ohne Probleme für Python 3.4 angewendet werden.
Vorraussetzung für die Installation von Python 3.5 ist eine lauffähige CentOS 7 Installation. Die Installation von Python 3.5 erfolgt aus dem IUS-Repository. Wie dies eingebunden wird habe ich schon in dem Tutorial IUS Repo installieren gezeigt, daher wird dies hier nur ganz kurz erklärt.
Einbinden des IUS-Repositorys
Der Vorteil der Installation von Python 3.5 aus dem Repository gegenüber der „selbstgebauten Version“ ist, dass wir regelmäßig Updates aus dem Repo erhalten. Eine manuelle Pflege der Installation ist also nicht mehr nötig.
Mit folgenden Befehl binden wir das IUS-Repository ein.
|
yum install https://centos7.iuscommunity.org/ius-release.rpm |
Nachdem die Installation abgeschlossen ist können wir uns die optional verfügbaren Python-Versionen anschauen.
|
yum search python3 | grep '\<python3.u\>' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
python34u-debuginfo.x86_64 : Debug information for package python34u python35u-debuginfo.x86_64 : Debug information for package python35u python34u.x86_64 : Version 3 of the Python programming language aka Python 3000 python34u-debug.x86_64 : Debug version of the Python 3 runtime python34u-devel.x86_64 : Libraries and header files needed for Python 3 python34u-libs.x86_64 : Python 3 runtime libraries python34u-pip.noarch : A tool for installing and managing Python 3.4 packages python34u-redis.noarch : Python client for Redis key-value store python34u-setuptools.noarch : Easily build and distribute Python 3.4 packages python34u-test.x86_64 : The test modules from the main python 3 package python34u-tkinter.x86_64 : A GUI toolkit for Python 3 python34u-tools.x86_64 : A collection of tools included with Python 3 python34u-wheel.noarch : A built-package format for Python 3.4 python35u.x86_64 : Version 3 of the Python programming language aka Python 3000 python35u-debug.x86_64 : Debug version of the Python 3 runtime python35u-devel.x86_64 : Libraries and header files needed for Python 3 python35u-libs.x86_64 : Python 3 runtime libraries python35u-pip.noarch : A tool for installing and managing Python packages python35u-setuptools.noarch : Easily build and distribute Python packages python35u-test.x86_64 : The test modules from the main python 3 package python35u-tkinter.x86_64 : A GUI toolkit for Python 3 python35u-tools.x86_64 : A collection of tools included with Python 3 |
Wie die Ausgabe zeigt stehen uns nun die Versionen Python 3.4 und Python 3.5 zur Verfügung.
Python 3.5 unter CentOS 7 installieren
Der Rest ist nun eigentlich ganz einfach. Die gewüschte Version installieren wir nun wie gewohnt mit yum. In unserem Fall ist es das Paket python35u und ein paar weitere Pakete für unser Python Virtual Environment.
|
yum install python35u python35u-setuptools python35u-devel python35u-pip |
Nachdem auch diese Installation abgeschlossen ist können wir mit der Bereitstellung unseres Python Virtual Environment beginnen.
Virtual Environment für Python 3.5 erzeugen
Um ein Virtual Environment für Python 3.5 bereitzustellen müssen wir zuerst für unser installieres Python 3.5 virtualenv installieren. Das geht am einfachsten mit pip. Allerdings müssen wir dies passend zu unserer Python Version wählen.