What is the purpose of following command?

Hi,
I found a tutorial of web3.py but I can’t understand the following command:

$ python3 -m venv venv 

$ source ./venv/bin/activate

(venv) $

Then, install the packages using pip as follows:

(venv) $ pip install -U pip
(venv) $ pip install jupyterlab
(venv) $ pip install web3
(venv) $ pip install "web3[tester]"
(venv) $ pip install py-solc-x

Somebody please guide me what is the purpose of : $ python3 -m venv venv

Zulfi.

venv is a module to allow you to create virtual environments.

A virtual environment helps avoid dependency conflicts by creating an isolated workspace to develop a Python project. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

We have a nice article on virtual environments which explains their advantages and how to use them.

2 Likes