Setting Up Python Development Environment on Linux

Web & Data-intensive application development with Python is gaining popularity day by day for tools & frameworks like Django, Flask,  pyramid, NumPy, SciPy, pandas, Scikit-learn, etc. Using python frameworks in development helps the developers to increase productivity and build robust systems in very short time. 

  In this tutorial, we will show how to set up a Python development environment in any Debian Linux based operating system like Ubuntu, Linux Mint etc.


  For this tutorial, we are using Ubuntu-mate 20.04 LTS but not use the built-in Python version provided by the OS for regular development tasks. Instead, we will learn how to download, build & install the latest stable or any other python version using tools like pyenv.

 like https://github.com/pyenv/pyenv-installer.

To start with the process lets fire up the console and run the following commands:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade

After that, install the following packages required to build Python from source:
$ sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

After installing the must require dependencies lets install PyEnv

$ curl https://pyenv.run | bash
pyenv.run redirects to the install script in this repository and the invocation above are equivalent to:
$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

After installing the PyEnv put the following shell commands to ~/.bashrc file using vim or your favorite editor and save!

$ vim ~/.bashrc





export PATH="/home/asif/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

 

After saving this, you can install any python version using PyEnv shell commands and change the global/local version of your python interpreter as per your systems/projects need. 


Will revamp the tutorial and update it accordingly after the release of Ubuntu 22.04 LTS next April.

Comments