Setting up a Python developer environment
Developer environment is the environment a developer use to code without affecting his/her work laptop/PC; while installing additional packages and plugins required by end customer's defined specifications and not breaking daily work engine (laptop/PC). Some developers prefer to set up a separate virtual machine to muck around with their environment carefree but some don't really have much horsepower on their work laptop/PC to do so. In that case, virtual environment or venv comes in handy for the ones don't really like to setup a virtual machine and maintain/patch two different operating systems; one on the host machine and one on the VM.
In this tutorial, I will do a quick rundown on how you can quickly setup a developer environment with venv. Of course, I will use Ubuntu 20.04 LTS desktop as my distribution and try to install venv for Python 3
As always and oftentimes, it is the best practice to update the APT.
Install prerequisites packages and pip for Python 3
Then use pip to install virtualenv
Make a directory called py3 at your home directory for virtualenv
After that, make the newly created directory py3 as virtualenv for Python 3
Activate the Python 3 virtualenv
py3 is displayed as prefix at your terminal prompt as below. And now you are in the venv to start coding.
To leave the venv, type "deactivate" command at the prompt.
To make our life easier in the terminal, we can create an alias called py3 in .bashrc file at home directory. Add the following line in our .bashrc file by using your favorite text editor like vim or nano.
Now all we have to do is type "py3" at the prompt rather than "source py3/bin/activate" as below.
That's it! The virtual environment has been successfully setup as developer environment. Now you can start coding some python 3 in your developer environment.
Last updated