Skip to content

Instantly share code, notes, and snippets.

@k8scat
Last active May 7, 2021 04:00
Show Gist options
  • Save k8scat/1a8f09a55e4ae1b67448bc41df6d1b5c to your computer and use it in GitHub Desktop.
Save k8scat/1a8f09a55e4ae1b67448bc41df6d1b5c to your computer and use it in GitHub Desktop.
Install python3 from source code on CentOS 7.
#!/bin/bash
#
# Install python3 from source code on CentOS 7
# Maintainer: K8sCat <[email protected]>
set -e
if [[ $(id -u) -ne 0 ]]; then
echo "require root"
exit 1
fi
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
# if `gcc -v` less than 8.1.0, do not run `./configure` with --enable-optimizations param.
# if you did that, run `make distclean` to have a clean environment.
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
python3 -V
pip3 -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment