This is a cheat-sheet-style article based on information found on other online resources including manuals for Python, Virtual Environments, StackOverflow articles, etc
A bare Centos 7 comes with Python 2
Some OS utilities may install Python 3 as dependencies. Don't want to touch them to not break anything else
Hence, installing under local user will side step any dependency conflicts and allow a dedicated Python3 installation that can be used for Zapy SDK
Benefit - removing/reinstalling/upgrading this local Python3 installation becomes simple
With sudo/root privileges for this step only, install OS level dependency packages
sudo yum install gcc zlib zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi libffi-devel lzma
NOTE - If you are missing some of these dependencies, and still try to install python, you might have to reinstall..!
For the rest of these steps, do not use sudo/root
Python3 installation as regular user
version=3.9.12 version_short=3.9 wget https://www.python.org/ftp/python/$version/Python-$version.tgz tar xzf Python-$version.tgz cd Python-$version ./configure --enable-optimizations --enable-shared --prefix=$HOME/python$version LDFLAGS=-Wl,-rpath=$HOME/python$version/lib make altinstall # so it does not trash installed python2 or other system-preinstalled python version python$version_short -V echo "export PATH=$HOME/python$version/bin/:$PATH" >> ~/.bashrc echo "export PYTHONPATH=$HOME/python$version/bin" >> ~/.bashrc export PATH=$HOME/python$version/bin/:$PATH export PYTHONPATH=$HOME$version/python/bin
Virtual Environment configuration as regular user
~/python$version/bin/python$version_short -m venv ~/venv_3 source ~/venv_3/bin/activate pip install --upgrade pip setuptools # optional: echo "source ~/venv_3/bin/activate" >> ~/.bashrc
Please sign in to leave a comment.