Python Tips
This guide outlines the process of creating a directory, accessing it, setting up a Python virtual environment (.venv), and activating it.
Note
In Windows, the Python command is python, while in macOS and Linux systems it might be python3. Throughout this guide, we'll use python, but if you're on macOS or Linux and the command doesn't work, try using python3 instead.
Setup a new Python Project
Open the terminal and navigate to the directory that you want to initialize.
Create a Virtual Environment (.venv)
Inside the directory, create a Python virtual environment using the command:
bashpython -m venv .venvThe virtual environment will be created in the
.venvdirectory.Activate the virtual environment using the appropriate command for your operating system:
powershell.venv\Scripts\activateshellsource .venv/bin/activateOnce activated, the virtual environment's name (.venv) will appear at the beginning of the terminal prompt.
If you close the terminal session and starts a new one, please activate the environment again.
You are now ready to install dependencies and start developing your Python project!