Python library installations Python can be installed on its host machine or in a virtual environment. This is default directory after running the command below to create a virtual environment python -m venv ./venv - venv |-- bin | |-- Activate.ps1 | |-- activate | |-- activate.csh | |-- activate.fish | |-- pip | |-- pip3 | |-- pip3.10 | |-- python -> /usr/sbin/python | |-- python3 -> python | `-- python3.10 -> python |-- include |-- lib | `-- python3.10 | `-- site-packages | |-- _distutils_hack | |-- distutils-precedence.pth | |-- pip | |-- pip-22.0.4.dist-info | |-- pkg_resources | |-- setuptools | `-- setuptools-58.1.0.dist-info |-- lib64 -> lib `-- pyvenv.cfg This implies that the venv brings in the pip executable after running the command below python -m pip install typer==0.3.2 colorama==0.4.4 shellingham==1.4.0 Collecting typer==0.3.2 This is the how the directory now looks `-- venv |-- bin | |-- Activate.ps1 | |-- activate | |-- activate.csh | |-- activate.fish | |-- pip | |-- pip3 | |-- pip3.10 | |-- python -> /usr/sbin/python | |-- python3 -> python | `-- python3.10 -> python |-- include |-- lib | `-- python3.10 | `-- site-packages | |-- _distutils_hack | |-- click | |-- click-7.1.2.dist-info | |-- colorama | |-- colorama-0.4.4.dist-info | |-- distutils-precedence.pth | |-- pip | |-- pip-22.0.4.dist-info | |-- pkg_resources | |-- setuptools | |-- setuptools-58.1.0.dist-info | |-- shellingham | |-- shellingham-1.4.0.dist-info | |-- typer | `-- typer-0.3.2.dist-info |-- lib64 -> lib `-- pyvenv.cfg Apparently pip first detects the lib directory and the running python version , then pulls the dependencies into the directory Host Based Installation Before installing the Packages [0101c:~/.local/lib/python3.10/site-packages]└2 [venv] $ tree -L 1 . |-- __pycache__ |-- sec-0.3.0.dist-info `-- sec.py After running the command below on a new project directory python -m pip install typer==0.3.2 colorama==0.4.4 shellingham==1.4.0.0 The directory looked like the following [0101c:~/.local/lib/python3.10/site-packages]└2 [venv] $ tree -L 1 . |-- __pycache__ |-- click |-- click-7.1.2.dist-info |-- colorama |-- colorama-0.4.4.dist-info |-- sec-0.3.0.dist-info |-- sec.py |-- shellingham |-- shellingham-1.4.0.dist-info |-- typer `-- typer-0.3.2.dist-info Question/Research: 1. How does it know where to install this libraries when in the host 2. How does pip know it is in the host or in a virtual environment