Python

Python


 

Learning Python

http://learnpythonthehardway.org/book/

http://www.codecademy.com/en/tracks/python

Python User Group - Richmond, VA - https://www.meetup.com/PyRVAUserGroup/ 

Showing all available python modules

Three different ways of showing all available python modules

pip list

 

>>>help("modules")

>>>import sys

>>>print sys.modules

 

pip

pip is a package management tool for python.

pip is installed by default in many linux distributions.  To verify that pip is installed use the command:

which pip

If it is not installed, you need to manually install pip do the following:

http://www.pip-installer.org/en/latest/installing.html

Some python modules are installed by default by the operating system, but there are many more that can be installed. Not all modules are compatible with other modules, so they are not installed by default.
A user can use pip to install modules into a user's home directory without the need for administrator privileges:

pip install --user <module>

modules will be downloaded, compiled, and installed under ~/.local

To show all installed python modules use:

pip list

To search for  python modules available for installation use:

pip search <module>

Before installing other modules, its recommend that pip and setuptools be updated:

pip install --user --upgrade pip 

pip install --user --upgrade setuptools


Users on a cluster should qrsh to get a shell on a compute node before installing new packages.

pyenv

pyenv allows for multiple version of python to be installed in a users home directory and they are able to switch from one to another.  If a user needs a version of python that is not installed by default, they can use pyenv to any almost any version they wish in their home directory.  They can then use pip that comes with that version to install the modules they want. Read the documentation for pyenv before using these direction.

Documentation

 

Install pyenv

( also installs easy_install and pip )

 

If you are on a cluster, use qrsh to obtain a shell on a compute node.

 

cd
git clone https://github.com/pyenv/pyenv.git .pyenv

 

Create a file to set the correct environmental variables for pyenv

Create a file called ~/enable_pyenv.sh with the following lines:

 

echo 'export PYENV_ROOT="$HOME/.pyenv"' > ./enable_pyenv.sh
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ./enable_pyenv.sh
echo 'eval "$(pyenv init --path)"' >> ./enable_pyenv.sh
echo 'eval "$(pyenv init -)"' >> ./enable_pyenv.sh

 

At this point, if you are on a cluster, use qrsh to get a shell on a compute node.

 

activate these variables with the source command:

 

source ~/enable_pyenv.sh

 

If you want these to be set with every login, add "source ~/enable_pyenv.sh" to your ~/.bash_profile

 

Verify pyenv is installed:

which pyenv

pyenv --version

 

Show all available python version that can be installed


If you need a version of python3, its recommended to use the latest version of 3.6 or above since its likely to be used on future servers. But, not all python modules are available for every version of python, research supported version for a desired module.

pyenv install --list

Output will be a huge list of python versions and should look something like the output below

$ pyenv install --list Available versions: 2.1.3 2.2.3 2.3.7 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7-dev 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.15 2.7.16 2.7.17 2.7.18 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4-dev 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.4.10 3.5.0 3.5-dev 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.5.10 3.6.0 3.6-dev 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.6.10 3.6.11 3.6.12 3.6.13 3.6.14 3.6.15 3.7.0 3.7-dev 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.15 3.7.16 3.8.0 3.8-dev 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.10 3.8.11 3.8.12 3.8.13 3.8.14 3.8.15 3.8.16 3.9.0 3.9-dev 3.9.1 3.9.2 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.10.0 3.10-dev 3.10.1 3.10.2 3.10.3 3.10.4 3.10.5 3.10.6 3.10.7 3.10.8 3.10.9 3.11.0 3.11-dev 3.11.1 3.12.0a4 3.12-dev activepython-2.7.14 activepython-3.5.4 activepython-3.6.0 anaconda-1.4.0 anaconda-1.5.0 anaconda-1.5.1 anaconda-1.6.0 anaconda-1.6.1 anaconda-1.7.0 anaconda-1.8.0 anaconda-1.9.0 anaconda-1.9.1 anaconda-1.9.2 anaconda-2.0.0 anaconda-2.0.1 anaconda-2.1.0 anaconda-2.2.0 anaconda-2.3.0 anaconda-2.4.0 anaconda-4.0.0 anaconda2-2.4.0 anaconda2-2.4.1 anaconda2-2.5.0 anaconda2-4.0.0 anaconda2-4.1.0 anaconda2-4.1.1 anaconda2-4.2.0 anaconda2-4.3.0 anaconda2-4.3.1 anaconda2-4.4.0 anaconda2-5.0.0 anaconda2-5.0.1 anaconda2-5.1.0 anaconda2-5.2.0 anaconda2-5.3.0 anaconda2-5.3.1 anaconda2-2018.12 anaconda2-2019.03 anaconda2-2019.07 anaconda2-2019.10 anaconda3-2.0.0 anaconda3-2.0.1 anaconda3-2.1.0 anaconda3-2.2.0 anaconda3-2.3.0 anaconda3-2.4.0 anaconda3-2.4.1 anaconda3-2.5.0 anaconda3-4.0.0 anaconda3-4.1.0 anaconda3-4.1.1 anaconda3-4.2.0 anaconda3-4.3.0 anaconda3-4.3.1 anaconda3-4.4.0 anaconda3-5.0.0 anaconda3-5.0.1 anaconda3-5.1.0 anaconda3-5.2.0 anaconda3-5.3.0 anaconda3-5.3.1 anaconda3-2018.12 anaconda3-2019.03 anaconda3-2019.07 anaconda3-2019.10 anaconda3-2020.02 anaconda3-2020.07 anaconda3-2020.11 anaconda3-2021.04 anaconda3-2021.05 anaconda3-2021.11 anaconda3-2022.05 anaconda3-2022.10 cinder-3.8-dev graalpy-22.3.0 graalpython-20.1.0 graalpython-20.2.0 graalpython-20.3.0 graalpython-21.0.0 graalpython-21.1.0 graalpython-21.2.0 graalpython-21.3.0 graalpython-22.0.0 graalpython-22.1.0 graalpython-22.2.0 ironpython-dev ironpython-2.7.4 ironpython-2.7.5 ironpython-2.7.6.3 ironpython-2.7.7 jython-dev jython-2.5.0 jython-2.5-dev jython-2.5.1 jython-2.5.2 jython-2.5.3 jython-2.5.4-rc1 jython-2.7.0 jython-2.7.1 jython-2.7.2 mambaforge-pypy3 mambaforge mambaforge-4.10.1-4 mambaforge-4.10.1-5 mambaforge-4.10.2-0 mambaforge-4.10.3-0 mambaforge-4.10.3-1 mambaforge-4.10.3-2 mambaforge-4.10.3-3 mambaforge-4.10.3-4 mambaforge-4.10.3-5 mambaforge-4.10.3-6 mambaforge-4.10.3-7 mambaforge-4.10.3-8 mambaforge-4.10.3-9 mambaforge-4.10.3-10 mambaforge-4.11.0-0 mambaforge-4.11.0-1 mambaforge-4.11.0-2 mambaforge-4.11.0-3 mambaforge-4.11.0-4 mambaforge-4.12.0-0 mambaforge-4.12.0-1 mambaforge-4.12.0-2 mambaforge-4.12.0-3 mambaforge-4.13.0-1 mambaforge-4.14.0-0 mambaforge-4.14.0-1 mambaforge-4.14.0-2 mambaforge-22.9.0-0 mambaforge-22.9.0-1 mambaforge-22.9.0-2 mambaforge-22.9.0-3 micropython-dev micropython-1.9.3 micropython-1.9.4 micropython-1.10 micropython-1.11 micropython-1.12 micropython-1.13 micropython-1.14 micropython-1.15 micropython-1.16 micropython-1.17 micropython-1.18 micropython-1.19.1 miniconda-latest miniconda-2.2.2 miniconda-3.0.0 miniconda-3.0.4 miniconda-3.0.5 miniconda-3.3.0 miniconda-3.4.2 miniconda-3.7.0 miniconda-3.8.3 miniconda-3.9.1 miniconda-3.10.1 miniconda-3.16.0 miniconda-3.18.3 miniconda2-latest miniconda2-2.7-4.8.3 miniconda2-3.18.3 miniconda2-3.19.0 miniconda2-4.0.5 miniconda2-4.1.11 miniconda2-4.3.14 miniconda2-4.3.21 miniconda2-4.3.27 miniconda2-4.3.30 miniconda2-4.3.31 miniconda2-4.4.10 miniconda2-4.5.1 miniconda2-4.5.4 miniconda2-4.5.11 miniconda2-4.5.12 miniconda2-4.6.14 miniconda2-4.7.10 miniconda2-4.7.12 miniconda3-latest miniconda3-2.2.2 miniconda3-3.0.0 miniconda3-3.0.4 miniconda3-3.0.5 miniconda3-3.3.0 miniconda3-3.4.2 miniconda3-3.7.0 miniconda3-3.7-4.8.2 miniconda3-3.7-4.8.3 miniconda3-3.7-4.9.2 miniconda3-3.7-4.10.1 miniconda3-3.7-4.10.3 miniconda3-3.7-4.11.0 miniconda3-3.7-4.12.0 miniconda3-3.7-22.11.1-1 miniconda3-3.8.3 miniconda3-3.8-4.8.2 miniconda3-3.8-4.8.3 miniconda3-3.8-4.9.2 miniconda3-3.8-4.10.1 miniconda3-3.8-4.10.3 miniconda3-3.8-4.11.0 miniconda3-3.8-4.12.0 miniconda3-3.8-22.11.1-1 miniconda3-3.9.1 miniconda3-3.9-4.9.2 miniconda3-3.9-4.10.1 miniconda3-3.9-4.10.3 miniconda3-3.9-4.11.0 miniconda3-3.9-4.12.0 miniconda3-3.9-22.11.1-1 miniconda3-3.10.1 miniconda3-3.10-22.11.1-1 miniconda3-3.16.0 miniconda3-3.18.3 miniconda3-3.19.0 miniconda3-4.0.5 miniconda3-4.1.11 miniconda3-4.2.12 miniconda3-4.3.11 miniconda3-4.3.14 miniconda3-4.3.21 miniconda3-4.3.27 miniconda3-4.3.30 miniconda3-4.3.31 miniconda3-4.4.10 miniconda3-4.5.1 miniconda3-4.5.4 miniconda3-4.5.11 miniconda3-4.5.12 miniconda3-4.6.14 miniconda3-4.7.10 miniconda3-4.7.12 miniforge-pypy3 miniforge3-latest miniforge3-4.9.2 miniforge3-4.10 miniforge3-4.10.1-1 miniforge3-4.10.1-3 miniforge3-4.10.1-5 miniforge3-4.10.2-0 miniforge3-4.10.3-0 miniforge3-4.10.3-1 miniforge3-4.10.3-2 miniforge3-4.10.3-3 miniforge3-4.10.3-4 miniforge3-4.10.3-5 miniforge3-4.10.3-6 miniforge3-4.10.3-7 miniforge3-4.10.3-8 miniforge3-4.10.3-9 miniforge3-4.10.3-10 miniforge3-4.11.0-0 miniforge3-4.11.0-1 miniforge3-4.11.0-2 miniforge3-4.11.0-3 miniforge3-4.11.0-4 miniforge3-4.12.0-0 miniforge3-4.12.0-1 miniforge3-4.12.0-2 miniforge3-4.12.0-3 miniforge3-4.13.0-0 miniforge3-4.13.0-1 miniforge3-4.14.0-0 miniforge3-4.14.0-1 miniforge3-4.14.0-2 miniforge3-22.9.0-0 miniforge3-22.9.0-1 miniforge3-22.9.0-2 miniforge3-22.9.0-3 nogil-3.9.10 nogil-3.9.10-1 pypy-c-jit-latest pypy-dev pypy-stm-2.3 pypy-stm-2.5.1 pypy-1.5-src pypy-1.6 pypy-1.7 pypy-1.8 pypy-1.9 pypy-2.0-src pypy-2.0 pypy-2.0.1-src pypy-2.0.1 pypy-2.0.2-src pypy-2.0.2 pypy-2.1-src pypy-2.1 pypy-2.2-src pypy-2.2 pypy-2.2.1-src pypy-2.2.1 pypy-2.3-src pypy-2.3 pypy-2.3.1-src pypy-2.3.1 pypy-2.4.0-src pypy-2.4.0 pypy-2.5.0-src pypy-2.5.0 pypy-2.5.1-src pypy-2.5.1 pypy-2.6.0-src pypy-2.6.0 pypy-2.6.1-src pypy-2.6.1 pypy-4.0.0-src pypy-4.0.0 pypy-4.0.1-src pypy-4.0.1 pypy-5.0.0-src pypy-5.0.0 pypy-5.0.1-src pypy-5.0.1 pypy-5.1-src pypy-5.1 pypy-5.1.1-src pypy-5.1.1 pypy-5.3-src pypy-5.3 pypy-5.3.1-src pypy-5.3.1 pypy-5.4-src pypy-5.4 pypy-5.4.1-src pypy-5.4.1 pypy-5.6.0-src pypy-5.6.0 pypy-5.7.0-src pypy-5.7.0 pypy-5.7.1-src pypy-5.7.1 pypy2-5.3-src pypy2-5.3 pypy2-5.3.1-src pypy2-5.3.1 pypy2-5.4-src pypy2-5.4 pypy2-5.4.1-src pypy2-5.4.1 pypy2-5.6.0-src pypy2-5.6.0 pypy2-5.7.0-src pypy2-5.7.0 pypy2-5.7.1-src pypy2-5.7.1 pypy2.7-5.8.0-src pypy2.7-5.8.0 pypy2.7-5.9.0-src pypy2.7-5.9.0 pypy2.7-5.10.0-src pypy2.7-5.10.0 pypy2.7-6.0.0-src pypy2.7-6.0.0 pypy2.7-7.0.0-src pypy2.7-7.0.0 pypy2.7-7.1.0-src pypy2.7-7.1.0 pypy2.7-7.1.1-src pypy2.7-7.1.1 pypy2.7-7.2.0-src pypy2.7-7.2.0 pypy2.7-7.3.0-src pypy2.7-7.3.0 pypy2.7-7.3.1-src pypy2.7-7.3.1 pypy2.7-7.3.2-src pypy2.7-7.3.2 pypy2.7-7.3.3-src pypy2.7-7.3.3 pypy2.7-7.3.4-src pypy2.7-7.3.4 pypy2.7-7.3.5-src pypy2.7-7.3.5 pypy2.7-7.3.6-src pypy2.7-7.3.6 pypy2.7-7.3.8-src pypy2.7-7.3.8 pypy2.7-7.3.9-src pypy2.7-7.3.9 pypy2.7-7.3.10-src pypy2.7-7.3.10 pypy2.7-7.3.11-src pypy2.7-7.3.11 pypy3-2.3.1-src pypy3-2.3.1 pypy3-2.4.0-src pypy3-2.4.0 pypy3.3-5.2-alpha1-src pypy3.3-5.2-alpha1 pypy3.3-5.5-alpha-src pypy3.3-5.5-alpha pypy3.5-c-jit-latest pypy3.5-5.7-beta-src pypy3.5-5.7-beta pypy3.5-5.7.1-beta-src pypy3.5-5.7.1-beta pypy3.5-5.8.0-src pypy3.5-5.8.0 pypy3.5-5.9.0-src pypy3.5-5.9.0 pypy3.5-5.10.0-src pypy3.5-5.10.0 pypy3.5-5.10.1-src pypy3.5-5.10.1 pypy3.5-6.0.0-src pypy3.5-6.0.0 pypy3.5-7.0.0-src pypy3.5-7.0.0 pypy3.6-7.0.0-src pypy3.6-7.0.0 pypy3.6-7.1.0-src pypy3.6-7.1.0 pypy3.6-7.1.1-src pypy3.6-7.1.1 pypy3.6-7.2.0-src pypy3.6-7.2.0 pypy3.6-7.3.0-src pypy3.6-7.3.0 pypy3.6-7.3.1-src pypy3.6-7.3.1 pypy3.6-7.3.2-src pypy3.6-7.3.2 pypy3.6-7.3.3-src pypy3.6-7.3.3 pypy3.7-c-jit-latest pypy3.7-7.3.2-src pypy3.7-7.3.2 pypy3.7-7.3.3-src pypy3.7-7.3.3 pypy3.7-7.3.4-src pypy3.7-7.3.4 pypy3.7-7.3.5-src pypy3.7-7.3.5 pypy3.7-7.3.6-src pypy3.7-7.3.6 pypy3.7-7.3.7-src pypy3.7-7.3.7 pypy3.7-7.3.8-src pypy3.7-7.3.8 pypy3.7-7.3.9-src pypy3.7-7.3.9 pypy3.8-7.3.6-src pypy3.8-7.3.6 pypy3.8-7.3.7-src pypy3.8-7.3.7 pypy3.8-7.3.8-src pypy3.8-7.3.8 pypy3.8-7.3.9-src pypy3.8-7.3.9 pypy3.8-7.3.10-src pypy3.8-7.3.10 pypy3.8-7.3.11-src pypy3.8-7.3.11 pypy3.9-7.3.8-src pypy3.9-7.3.8 pypy3.9-7.3.9-src pypy3.9-7.3.9 pypy3.9-7.3.10-src pypy3.9-7.3.10 pypy3.9-7.3.11-src pypy3.9-7.3.11 pyston-2.2 pyston-2.3 pyston-2.3.1 pyston-2.3.2 pyston-2.3.3 pyston-2.3.4 pyston-2.3.5 stackless-dev stackless-2.7-dev stackless-2.7.2 stackless-2.7.3 stackless-2.7.4 stackless-2.7.5 stackless-2.7.6 stackless-2.7.7 stackless-2.7.8 stackless-2.7.9 stackless-2.7.10 stackless-2.7.11 stackless-2.7.12 stackless-2.7.14 stackless-2.7.16 stackless-3.2.2 stackless-3.2.5 stackless-3.3.5 stackless-3.3.7 stackless-3.4-dev stackless-3.4.2 stackless-3.4.7 stackless-3.5.4 stackless-3.7.5

 

There are many versions of python supported by pyenv. Most users want the latest version of 2.7.x or 3.7.x or above

Note: Python 2.7 will reach the end of its life on January 1st, 2020

 

Install Python 3.7.16

Basic Install:

 

pyenv install 3.7.16

 


Advanced install, creates log of install process:

 

pyenv install 3.7.16 -v 2>&1 | tee pyenv-install-3.7.16.log

 

The install takes several minutes to complete after the "Installing ..." message appears.

 

Troubleshooting Install problems


See https://github.com/pyenv/pyenv/wiki/common-build-problems

 

Show current python

which python
python -V

$ pyenv versions
system
* 3.7.16 (set by .python-version)


Switch to different version of python and show it


python -V
which python
pyenv local 3.7.16

python -V
which python

 

Note: when using pip from within the pyenv environment, there is no need to use the --user switch, because you have access to default python directories for version you have installed.

 

Update pip and setuptools

Before installing any new modules, its recommended to update pip and setuptools, which are used to install modules.


pip install --upgrade pip setuptools

or

python -m pip install --upgrade pip setuptools

 

 

Installing packages

pip install <package>

 

$ pip install numpy
Collecting numpy
Using cached numpy-1.19.5-cp36-cp36m-manylinux2010_x86_64.whl (14.8 MB)
Installing collected packages: numpy
Successfully installed numpy-1.19.5

 

Listing packages

 

This is list all installed packages

 

pip list

 

 

Installing pyenv in a shared directory

 

Installing in a shared directory is similar to installing in a user's home directory, but a change needs to be made to the source file to enable pyenv

 

In this example the shared directory is /vcu_gpfs2/home/sharedtest  pyenv is installed at /vcu_gpfs2/home/sharedtest/.pyenv

 

 

cd /vcu_gpfs2/home/sharedtest

git clone git://github.com/yyuu/pyenv.git .pyenv

# create source file, note the shared directory name is listed explicitly, change it for your directory
echo 'export PYENV_ROOT="/vcu_gpfs2/home/sharedtest/.pyenv"' > ./enable_pyenv.sh
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ./enable_pyenv.sh
echo 'eval "$(pyenv init --path)"' >> ./enable_pyenv.sh
echo 'eval "$(pyenv init -)"' >> ./enable_pyenv.sh

# enable the pyenv in the shared directory
source /vcu_gpfs2/home/sharedtest/enable_pyenv.sh

# verify you are using the pyenv in the shared directory:
which pyenv

output should look like this:
/vcu_gpfs2/home/sharedtest/.pyenv/bin/pyenv


All other commands should work normally

Considerations for installing pyenv on Centos 6

 

Always get a qrsh shell to one of the cluster nodes

 

If a newer version of gcc is required, add the following line to enable_pyenv.sh:

source /opt/rh/devtoolset-7/enable

 

If a newer version of openssl is required, add the following line to enable_pyenv.sh:

source /usr/global/openssl/enable_openssl.sh

 

If you installed pyenv, add those lines to the begining of the enable_pyenv.sh file mentioned above.

 

 

Installing openssl 1.1.1

This is necessary for Centos 6 systems in order to install python 3.7.x  . This has already been done for godel  and is found at /usr/global/openssl

mkdir src/openssl-1.1.1s
cd src/openssl-1.1.1s

wget https://www.openssl.org/source/openssl-1.1.1s.tar.gz -O openssl-1.1.1s.tar.gz

tar -zxf openssl-1.1.1s.tar.gz

cd openssl-1.1.1s

./config --prefix=/usr/global/openssl-1.1.1s --openssldir=/usr/global/openssl-1.1.1s shared zlib 2>&1 | tee config-$(date +%F-%H%M).log

make 2>&1 | tee make-$(date +%F-%H%M).log

make test 2>&1 | tee make-test-$(date +%F-%H%M).log

make install 2>&1 | tee make-install-$(date +%F-%H%M).log

 

Error: Could not find a version that satisfies the requirement

 

When trying to install modules with pip, if the following error comes up:

 

$ pip install numpy
Collecting numpy
/home/cgchildr/.pyenv/versions/2.7.14/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy 

 

You'll need to first install updated version of openssl using the following command:

 

$ pip install --trusted-host pypi.python.org pyOpenSSL ndg-httpsclient pyasn1
Collecting pyOpenSSL
/home/cgchildr/.pyenv/versions/2.7.14/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
  Downloading pyOpenSSL-17.5.0-py2.py3-none-any.whl (53kB)
    100% |████████████████████████████████| 61kB 6.0MB/s
Collecting ndg-httpsclient
  Downloading ndg_httpsclient-0.4.4-py2-none-any.whl
Collecting pyasn1
  Downloading pyasn1-0.4.2-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 17.8MB/s
Collecting six>=1.5.2 (from pyOpenSSL)
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting cryptography>=2.1.4 (from pyOpenSSL)
  Downloading cryptography-2.2.2-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
    100% |████████████████████████████████| 2.2MB 18.8MB/s
Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography>=2.1.4->pyOpenSSL)
  Downloading cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl (407kB)
    100% |████████████████████████████████| 409kB 16.3MB/s
Collecting enum34; python_version < "3" (from cryptography>=2.1.4->pyOpenSSL)
  Downloading enum34-1.1.6-py2-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=2.1.4->pyOpenSSL)
  Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
    100% |████████████████████████████████| 102kB 16.9MB/s
Collecting idna>=2.1 (from cryptography>=2.1.4->pyOpenSSL)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 14.8MB/s
Collecting ipaddress; python_version < "3" (from cryptography>=2.1.4->pyOpenSSL)
  Downloading ipaddress-1.0.19.tar.gz
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=2.1.4->pyOpenSSL)
  Downloading pycparser-2.18.tar.gz (245kB)
    100% |████████████████████████████████| 256kB 18.0MB/s
Installing collected packages: six, pycparser, cffi, enum34, asn1crypto, idna, ipaddress, cryptography, pyOpenSSL, pyasn1, ndg-httpsclient
  Running setup.py install for pycparser ... done
  Running setup.py install for ipaddress ... done
Successfully installed asn1crypto-0.24.0 cffi-1.11.5 cryptography-2.2.2 enum34-1.1.6 idna-2.6 ipaddress-1.0.19 ndg-httpsclient-0.4.4 pyOpenSSL-17.5.0 pyasn1-0.4.2 pycparser-2.18 six-1.11.0 

 

After that, python modules with install normally:

 

$ pip install numpy
Collecting numpy
/home/cgchildr/.pyenv/versions/2.7.14/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
  Downloading numpy-1.14.2-cp27-cp27mu-manylinux1_x86_64.whl (12.1MB)
    100% |████████████████████████████████| 12.1MB 66kB/s
Installing collected packages: numpy
Successfully installed numpy-1.14.2 

 

Example: Install Python 3.8.16 under Centos 6 on godel

 

On godel first do: qrsh

On servers with Centos 6 ( like godel ) an updated version of openssl must be used with python 3.7.x, do the following to install python 3.7.x with pyenv:

 

source ~/enable_pyenv.sh
source /opt/rh/devtoolset-7/enable
source /usr/global/openssl/enable_openssl.sh

# verify gcc and openssl are updated
which gcc
which openssl

export LDFLAGS="-Wl,-rpath,/usr/global/openssl/lib"
export CPPFLAGS="-I/usr/global/openssl/include"
export CONFIGURE_OPTS="--with-openssl=/usr/global/openssl"

pyenv install 3.8.13 -v 2>&1 | tee pyenv-install-3.8.13.log




 

The install takes several minutes to complete after the "Installing ..." message appears.

 


Remove pyenv

 

remove ( or move ) the following

rm -rf ~/.pyenv

rm ~/.python-version

rm ~/enable_pyenv.sh

 

pipenv

 

research