How to install Python 3.10 on CentOS 7

First, install the dependency

yum install -y wget zlib-devel
yum groupinstall -y "Development tools"

Install OpenSSL as the openssl-devel package provided by CentOS is old version. Install OpenSSL from source with

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar xvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/usr/serverok/openssl --openssldir=/usr/serverok/openssl no-ssl2
make
make install

Run following commands

export PATH=/usr/serverok/openssl/bin:$PATH
export LD_LIBRARY_PATH=/usr/serverok/openssl/lib
export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L/usr/serverok/openssl/lib -Wl,-rpath,/usr/serverok/openssl/lib"

Download the latest version of Python from

https://www.python.org/downloads/

To install, run

cd /usr/local/src
wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tar.xz
tar xvf Python-3.10.6.tar.xz
cd /usr/local/src/Python-3.10.6
make clean && make distclean
./configure --enable-optimizations  --with-openssl=/usr/serverok/openssl/
make altinstall

Python 10 will be installed in folder

/usr/local/bin/python3.10

To install pip modules, you can use

python3.10 -m pip install -r requirements.txt 

Back to Python

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *