Last active
May 22, 2019 11:05
-
-
Save StudioSpindle/3209e7fa9bbbb5a0a62cf5b870c2eb03 to your computer and use it in GitHub Desktop.
Installs python3 on CentOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/bin/bash | |
# Problem: | |
# CentOS ships with Python as a critical part of the base system. | |
# Because it is a critical part it is not getting updated, other than to plug security vulnerabilities. | |
# CentOS 7 users are stuck with Python 2.7.5 released in May 2013. | |
# Utilities such as yum will break if the default Python interpreter is upgraded or replaced. | |
# The trick is to install new versions of Python in /usr/local (or some other non-standard location) so that | |
# they can live side-by-side with the system version. | |
# source: https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/ | |
# make sure the system is up-to-date: | |
yum update | |
# Compilers and related tools: | |
yum groupinstall -y "development tools" | |
# Libraries needed during compilation to enable all features of Python: | |
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel libffi-devel | |
# If you are on a clean "minimal" install of CentOS you also need the wget tool: | |
yum install -y wget | |
# Python 3.7.2 (this will take a while...): | |
wget http://python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz | |
tar xf Python-3.7.2.tar.xz | |
cd Python-3.7.2 | |
./configure --prefix=/usr/local --enable-optimizations --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
make && make altinstall | |
# Test if it works | |
Python3.7 -V | |
pip3.7 -V | |
# remember, to install via pip use: | |
# pip3.7 install <package> | |
# (! and not: pip install <package>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment