Member-only story
Virtual Environments, pip and pipenv on MacOS
When starting a new python project, our considerations might be if a project can be shared between co-workers and deployed to a production environment.
Virtual Environments’ Motivation
Virtual environment is Python’s way of creating an encapsulated environment where all your project specific packages live and run, it prevents the pollution of the global (or system) packages.
Imagine you have 2 different projects that live in different folders. Each of these projects should have its’ own virtual environment which can be activated and deactivated when needed. All packages can be installed in specific folders that these virtual environment are defined.
Installing, Removing, Activating and Deactivating Virtual Environments
Python3
To install virtual environment using Python3, we can set this up by creating a project folder.
$ mkdir /project-folder$ cd /project-folder$ python3 -m venv ./venv
When we run python3 -m venv
we are installing a new virtual environment and specifying the venv
folder as the folder where all virtual environment dependent files will exist.