Python 3.10.2 Centos 7 Install & Problems

Problems

I needed to update Python in one of my forgotten labs from 3.6 as Netmiko required 3.7 or higher.

Netmiko Version 4.1.2 requires Python Version 3.7 or higher. 🐍

So a quick Google and what I thought would be a straightforward install.
Turns out it wasn’t. CentOS 7 has a bug that complains about the SSL modules in Python not being available.

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

The fix to this came from the Python bug tracker: https://bugs.python.org/issue47201
Before running the “make” command be sure to run the following

sudo yum install -y epel
sudo yum install -y openssl11-devel
sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure

Python Installation

Update CentOS

yum update

Install necessary packages

sudo yum install openssl-devel bzip2-devel libffi-devel -y
sudo yum groupinstall "Development Tools" -y
sudo yum install wget -y

Download and extract Python

wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz
tar -xzf Python-3.10.2.tgz

cd into the extracted Python directory

cd Python-3.10.2

Run the following, this is where we will ensure that for CentOS 7 we patch the bug.

./configure --enable-optimizations
#Patch for Centos7 bug
sudo yum install -y epel
sudo yum install -y openssl11-devel
sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
make altinstall

pATH pROBLEM

I had an error complaining about the fact that pip was no on PATH.

Error: WARNING: The scripts pip, pip3 and pip3.10 are installed in '/home/centos/.local/bin' which is not on PATH.

Fixed with the following

export PATH="/home/centos/.local/bin:$PATH"
source ~/.bash_profile

Check

#Before
-bash-4.2$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin

#After
-bash-4.2$ echo $PATH
/home/centos/.local/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin

Install Virtual Environments

-bash-4.2$ python3.10 -m pip install virtualenv
Defaulting to user installation because normal site-packages is not writeable
Collecting virtualenv
  Downloading virtualenv-20.16.4-py3-none-any.whl (8.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.8/8.8 MB 2.7 MB/s eta 0:00:00
Collecting platformdirs<3,>=2.4
  Downloading platformdirs-2.5.2-py3-none-any.whl (14 kB)
Collecting distlib<1,>=0.3.5
  Downloading distlib-0.3.6-py2.py3-none-any.whl (468 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.5/468.5 kB 2.7 MB/s eta 0:00:00
Collecting filelock<4,>=3.4.1
  Downloading filelock-3.8.0-py3-none-any.whl (10 kB)
Installing collected packages: distlib, platformdirs, filelock, virtualenv
Successfully installed distlib-0.3.6 filelock-3.8.0 platformdirs-2.5.2 virtualenv-20.16.4

Leave a Comment

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