Irtiza

Aug 28, 2021

2 min read

Python and its Packages Version Management

python
https://miro.medium.com/max/1400/0*8aY8pX5CoNGImZU4.png

Overview

Assumptions

Pre-Requisites

  1. Virtual environment

Guidelines

  1. Install all the dependencies that are required by python3.
$ sudo yum -y install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel 
$ tar xJf <file-name>.tar.xz 
$ cd <file-name>.tar.xz
$ ./configure
$ make
$ sudo make altinstall # if a version is already installed other remove the "alt" and just run install
$ python3 -version
pythonX.X
pythonX.Xm
pythonX.Xm-config
sudo python<version> -m pip install <package-name>
/usr/local/lib/pythonX.X/site-packages
  • Using venv
# To create a virtual environment using venv
$ python3 -m venv ENV_NAME
# To activate it
$ source ENV_NAME/bin/activate
# To deactivate it
$ deactivate
  • Using virtualenv
# To install virtualenv
$ sudo pip3 install virtualenv
# if it is not available on cli check if it exists in /usr/bin. If not check the /usr/local/bin directory and move it to /usr/bin.# To create a virtual environment using virtualenv
$ python3 -m venv ENV_NAME
# To activate it
$ source ENV_NAME/bin/activate
# To deactivate it
$ deactivate
$ pythonX -m IPython

Final Thoughts