venv

konstantinosblatsoukasrepo

Konstantinos Blatsoukas

Posted on October 15, 2024

venv

python vevnv

Is used for separating packages versions per project.
For example, one project may use a package named foo-1-0, but another project uses foo-2-0.
We can not separate them using the global environment.
The solution is, to create two different virtual environemnts.

list all global packages

pip list # list all packages
Enter fullscreen mode Exit fullscreen mode

create a new virtual environment

# a new virtual environment with name project_env will be craeted
python -m venv project_env 
Enter fullscreen mode Exit fullscreen mode

activate venv

activate

# activate on ubuntu
source myenv/bin/activate
Enter fullscreen mode Exit fullscreen mode

deactivate venv

deactivate
Enter fullscreen mode Exit fullscreen mode

generate packages version for requirements.txt

pip freeze
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

generate required python packages

python -m venv vevn
source vevn/bin/activate
pip install pip-tools
pip-compile requirements.in
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
konstantinosblatsoukasrepo
Konstantinos Blatsoukas

Posted on October 15, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related