0

Lets say I have a reqirement.txt file which has this content (real file has more modules).

azure==4.0.0
google==3.0.0
requests==2.27.1
pyshark==0.4.5
pymysql==1.0.2
pandas==1.1.5

Okay, I install these packages using pip3 install -r requirements.txt

Next time when I want to run this command again, requirements file looks like this (updated pandas and added 2 more):

azure==4.0.0
google==3.0.0
requests==2.27.1
pyshark==0.4.5
pymysql==1.0.2
pandas==1.4.3
google-api-python-client==2.52.0
pytest-check==1.0.4

So, next time when i run the pip command i don't want to uninstall/install modules that i have not changed the version. Is there a way to run this command with a logic that if the version is the same, do nothing, if it is different uninstall old/install new, if it doesn't exist install it.

I know that there is --ignore-installed flag, but based on this answer here, it is risky to use

user14073111
  • 647
  • 5
  • 14
  • 1
    you can use `pipenv` for this – sahasrara62 Sep 08 '22 at 16:49
  • can you show me how? not familiar with this one.. – user14073111 Sep 08 '22 at 17:09
  • 1
    you can use pipenv to install new packages , it will create a piplock file to store package info, if new package is added with new version then it install those and update piplock file, with this piplock, you will fix all the version requirement and generate a new requirement.txt file – sahasrara62 Sep 08 '22 at 17:22

0 Answers0