You may have heard of virtual environments in nerd-social cycles but not actually considered what it is. It is a favourable option when writing code and scripts as a means of managing packages and modules. This contained and isolated space is a virtual environment (venv). You may wonder why you need a venv...

Imagine you are managing several different projects, some of which require specific versions of certain languages, perhaps python2.6 (for legacy isolated projects) and python 3.11 or something in between. venvs are not necessarily needed for different versions of python per se, but they pay dividends when developing various projects which require specific versions of modules or libraries to alleviate compatibility and version conflicts. As such, without venvs, it would cause conflicts when importing those modules and untold development headaches.

Installing a Virtual Env.

python3 -m pip install virtualenv

Using Virtual Env.

One liner: python3 -m venv .venv && source .venv/bin/activate

New environment

python3 -m venv .venv

Activate environment

source .venv/bin/activate

Deactivate environment

deactivate

Anaconda


References

Using Jupyter Notebook in Virtual Environment - GeeksforGeeks

What is Anaconda for Python & Why Should You Learn it?