Dynamically update virtual environment

432 views Asked by At

I have created a virtual environment for my Python project and have installed my requirement.txt in it and every time my Python code ex executes it first activate my virtual environment and then run the .py code which is what I want.

I have an issue here - I want to do everything programmatically. Below are the high level steps i'm looking for : 1)pipreqs requirements.txt using py code 2)check if .txt file has changed, create a flag(1,0)
3)check if virtualenv is created 2.1 - if not created, create and install 1 and run py code 2.2 - if created - check if flag=1 then re-install 1 and run py code if flag=0 , just run py code

I'm struggling hard to achieve this. Could somebody help.

1

There are 1 answers

0
Raphael On

maybe

pip install -r requirements.txt

is a good starting point (if your paint point is to manually install all the required libraries). It installs all the libraries listed in requirements.txt.

If this is not enough putting this command in a bash / cmd file might be an option.