Akhil Mathew
3 min readJul 12, 2020

--

Python3.8: From installation to setting up a virtual environment on ubuntu

  1. Install python 3.8 requirements.

2. Preparing your computer to build Python.

3. Pull down Python 3.8 from the official Python downloads section, build, and install.

Now you guys might be thinking what is this 'x' mentioned along with 3.8.x on the above URL. x simply denotes the patch update version number, which python releases over the time based on the bug fixes. When I write this story, the patch update is 3.
So the URL will be something like as follows.
https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz
That’s it. Python 3.8 has been installed and ready to be used.
You can Verify it by typing below command on your console or teminal
python3.8 --version

The output should show the Python version:

Python 3.8.0

4. How can I install pip for python 3?.

5. How to install the virtual environment and why you need it?.

A virtual environment is used to keep dependencies required by different projects separated by creating an isolated Python virtual environments for them.Why someone needs a virtual environment?Imagine a scenario where you are working on two projects based on python and one of your projects use Django version 2.x and the other use Django version 3.x. In such a scenario a virtual environment can be really useful to maintain dependencies of both the projects.Ideally, the virtual environment contaminates or bring social distancing between the packages. Thanks to COVID 19, Nowadays everyone knows the importance of social distancing. Same applicable when you deal with different projects based on python.
Tip: Even if you are working on a single project, try to create a virtual environment and then do.

How to create a virtual environment?.

Eg: virtualenv -p python3.8 venv

6. How you can use the virtual environment?.

To use the virtual environment, one must activate it.
Go inside the folder where you created the virtual environment using the above command. If you are already there, please remain the same.
Since you activated the virtual environment, you got constrained within the walls of this environment. Whatever you do after this will remains within these walls. Say, for example, if you install a package, then it will be applicable only for this environment.

7. How can I install packages in a virtual environment using python 3.8?.

Eg: python3.8 -m pip install Django==3.0.5

8. How can I see my installed packages?.

What you need to do is just freeze...!!!python3.8 -m pip freeze

Side note

You might have noticed that I used python3.8 rather than using python3 or simply python…

Hmm… Any idea??

Well, let me tell guide you…

Now you have multiple versions of Python installed on your machine. There’s a system default Python 2.7 (Exist on older Ubuntu versions, say 14 or 16), A system default Python 3. To that list, we added Python 3.8. Hurray…!!!

Now if you call python, which of this will listen?. It’s nothing but Python 2 default installation, i.e Python 2.7

If we call python3, the one which listen will be the default 3 installations like Python3.5 or Python3.6

If you want to use Python 3.8 version, you must use Python3.8

Eg: To run a python script, you can simply use command as followspython3.8 your-script.py

You might also be noticed that I used the -p flag while creating a virtual environment.

What is a -p flag in virtualenv…??

Well, it's just to inform the virtualenv that you want to create an environment for a specific version of python.

By default, there will be the version of python which is used for any new environment creation. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag

If you find this useful, please leave a comment. Having said that, I am signing off from this story…

Photo by kevin Xue on Unsplash

--

--

Akhil Mathew

A passionate coder + Photography enthusiast. Why am I here?. When we take something from the community, it’s our responsibility to contribute back.