1. Virtual Environments
This is the first, critical piece to modern software development with Python.
A Virtual Environment is required
PyCharm creates a venv by default when you create a new Project.
You can skip this step if you already have a Virtual Environment in your Project
What is a Virtual Environment?
Without Virtual Environments (venv or .venv), everything you install would be global to your machine. Every project you have would be sharing the same packages and dependencies which could cause clashes or unwanted side effects.
Luckily, venvs are easy to setup. Open a Terminal in the context of your Project Directory.
We assume you already have python3 installed on your machine
Download Python if you haven't already https://www.python.org/downloads/
Depending on your IDE, it should automatically detect that a Virtual Environment has been created and ask if it should use it. Accept :)
Otherwise, you can manually configure your IDE to use the Virtual Environment.
Kill all Terminal sessions, then reopen a Terminal. It should now open and activate the Virtual Environment automatically. This is indicated by the (venv) prefix as seen in the example below:
Real Python goes more in-depth on their website: Virtual Environments
Last updated