When working with Python, it’s best practice to use a separate virtual environment for each project to avoid dependency conflicts. Tools like PyCharm create virtual environments automatically, but you can just as easily do it via the command line:
-
cdto your project root and create a new virtual environmentRunning this command will create a
.venvfolder (a common name, but you can customize it if needed):
python3 -m venv .venv -
Activate the virtual environment
source .venv/bin/activate -
Once activated, your console should look like this:
(.venv) <user>@<computer> <FolderName>
You can leave the virtual environment by executing deactivate.
Top comments (0)