Virtual Environments


Virtual environments

Developing Machine Learning (ML) and Deep Learning (DL) projects have become more common. ML and DL are literary everywhere nowadays, from big corporations to schools and universities, and used in areas from medicine to robotics. But with the extensive use and variability of the projects where ML/DL is used, some problems need to tackle. When working on and developing such projects, the most common issue is the conflict between different libraries. This problem can easily be solved if we use virtual environments.

A virtual environment is precisely what the word describes, an environment, a sandbox, where we install libraries and software particular to the project we're working on. In data science, ML and DL, the Anaconda environments are the most well-known platforms used to create and manage virtual environments.

Anaconda environments offer a simple and elegant solution to manage our settings based on the project requirements we're working on. I think the power of anaconda environments comes from using a different version of python from a single installation. Also, we can easily use other anaconda repositories to install the GPU versions of ML/DL frameworks such as TensorFlow and PyTorch with ease.


The miniconda, a minimal version of Anaconda, will be installed here. Download the latest miniconda Linux installer script at Also, at Miniconda — Conda documentation, different miniconda installers and for other platforms (Windows, MacOSX, Linux).

Once the installer is downloaded, open a terminal and navigate to the location the script has been downloaded. For me is in /home/myusername/Downloads First, check and verify the integrity of the installer


and will get something similar to 4ee9c3aa53329cd7a63b49877c0babb49b19b7e5af29807b793a76bdb1d362b4 this value needs to compare it with the one given on the miniconda site. If the values much mean the download is not corrupted and can continue with the installation.

Then need to make the script executable (if it is not already) using the chmod command and then run the installer itself with the ./program-to-install This can be done by running the following command

chmod +x && ./

The installation procedure is pretty clear after that point. Need to scroll down to the end of EULA terms and conditions and type yes to agree with them.

Also, it is a good idea to agree with the default installation path, which is usually under the path /home/myusername/miniconda3. The installation directory can also be specified to a different location, but you need to add it to the path variable on your system to run miniconda.

The following prompt is essential and will ask to initialize miniconda after the installation and need to type yes. If following the default, no will need to initiaize miniconda manually. To do so need to manually initialize the shell you are using. For example, my shell is zsh, so the command will be conda init zsh and then need to restart your shell with

source ~/.zshrc

Now, the last step is not necessary, but Anaconda activates the base environment whenever you open your terminal by default, and I found that a bit annoying. So to remove the default functionality need to execute the following