Python Workflow
When working on multiple python projects, it’s important to create isolated environments for each project to avoid dependency conflicts. Here’s a recommended workflow using venv and pip.
Reference: Python Virtual Environments - Full Tutorial for Beginners
1 Create a Virtual Environment
On mac using Python 3, you can create a virtual environment under current working directory by running the following command in your terminal:
python3 -m venv env
2 Activate the virtual environment
source env/bin/activate
Simply type deactivate to exit the virtual environment when you’re done working.
3 Setup the environment
Use pip to install the pacakages you need for your project. For example: pip install matplotlib. Use pip list to show all installed packages in the virtual environment. You can use the requirements.txt file to install all the dependencies for your project. Refer to the Section 5 for more details.
5 Install dependencies from requirements.txt
After activating your virtual environment, you can install all the dependencies listed in the requirements.txt file by running:
pip install -r requirements.txt