Configuration
Virtual environmentsβ
Here are some configuration that comes in handy
A virtual environment in Python is crucial as it helps keep projects organized by creating separate spaces for development. This ensures a smooth workflow, avoids conflicts with different parts of the project, and makes version control easier, making Python programming projects more organized and manageable.
To display a list of all installed packages and their versions within the current virtual environment, run the following:
- Windows
- Linux
pip freeze
$ pip freeze
This information is often utilized for documenting dependencies, enabling others to recreate the same development environment with identical package versions.
To export the list in .txt
in your project directory:
- Windows
- Linux
pip freeze > requirements.txt
$ pip freeze > requirements.txt
Createβ
- Windows
- Linux
py -m venv .venv
$ python3 -m venv .venv
Activateβ
- Windows
- Linux
.\venv\scripts\activate
$ source .venv/bin/activate
Update / Upgradeβ
Updating your enviroment libraries to ensure smooth development is considered best practices. Once a requirements.txt
is present in your project dir, run the following:
- Windows
- Linux
py -m pip install --upgrade -r requirements.txt
$ python3 -m pip install --upgrade -r requirements.txt
To update pip
it itself, run the following:
- Windows
- Linux
py -m pip install --upgrade pip
$ python3 -m pip install --upgrade pip