'Google Colab: WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

I get the above WARNING while trying to pip install certain packages in Google Colab. I got this WARNING on executing the following line of code:

!pip uninstall -y enum34 && pip install --upgrade pip setuptools wheel && apt-get update && apt-get install ffmpeg libsm6 libxext6  -y

The warning statement says, to use a virtual environment. How can I setup a Virtual Environment in Google Colab with the venv module? I didn't find an accepted/satisfactory solution from here.

Also is there any better way, to solve the warning( I wish to solve it, not just get rid of it for namesake.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source