Best practice before creating python project to avoid dependencies error across programs is to code in virtual environment.
Go to desired directory in the terminal, then type in command line:
Windows:
python -m venv virtualEnvironmentNamep/s: Shorter name is better like venv or virt. For example:
python -m venv venvMac:
python3 -m venv virtualEnvironmentNameA directory of virtualEnvironmentName/ should be made in the selected path.
source virtualEnvironmentName/Scripts/activateNow, the (virtualEnvironmentName) should be shown in the Terminal above the directory:
Once the venv activated, continue working like normal in local machine.
deactivateThe output will be: Notice the (virtualEnvironmentName) is deactivated and not shown after the deactive command.
pip freezeFor a newly setup venv, nothing should be returned as it just freshly built.
After installing via pip install <libraryName>, the output should be e.g.:
At the end of the project, do this:
- Windows:
pip freeze > requirements.txt- Mac/Linux:
pip3 freeze > requirements.txtSo that, other user can simple recreate the venv via:
- Windows:
pip install -r requirements.txt- Max/Linux:
pip install -r requirements.txt

