# Build python3.8 on centos ###### tags: `c4lab` Python3.8.5 are used in this tutorial ## Download Python 3.8 Download lastest source from https://www.python.org/downloads/source/ ``` wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz tar xf Python-3.8.5.tar.xz cd Python-3.8.5 ``` ## Install Necessary packages ``` sudo yum install openssl-devel sqlite-devel libffi-devel cairo-devel tk-devel ``` * `openssl-devel` is necessary for `pip install` * `libffi-devel` is for `ctype` * `sqlite-devel` is for `sqlite3` * `tk-devel` is for X11 env. If gcc version is too old ``` $ sudo yum install devtoolset-9 $ scl enable devtoolset-9 bash ``` ## Run and Install ``` mkdir build cd build ../configure --prefix=$HOME/env/python3.8 --enable-optimizations --enable-loadable-sqlite-extensions make -j 16 make install -j 16 ``` ## Setup Environment ``` cd $HOME env/python3.8/bin/python3 -m venv env source $HOME/env/bin/activate ``` And you can set alias in `~/.bashrc` `alias pyenv="source $HOME/env/bin/activate"` ## Try ``` pip install jupyterlab ipython matplotlib ipython import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.show() ```