开发者

virtualenv requirements file - check existence of packages

开发者 https://www.devze.com 2023-03-27 14:03 出处:网络
I have a requirements file, where many of the libraries do not exist. To prune the file, I need to: - pip install -r requirements.txt

I have a requirements file, where many of the libraries do not exist. To prune the file, I need to: - pip install -r requirements.txt - see which library fails - delete the library from requirements.txt - repeat the process

This can be very tedious for 80+ files, where every lib in three or so fails... Is there a way to run a pre-check on the requirements file, obtaining a list of non-existent开发者_Python百科 libraries/versions?

Thanks


i found the code to check if a package is installed at this link:

http://code.activestate.com/recipes/440501-list-information-about-installed-python-packages-a/

maybe you can get something out from here.

cheers, Ste


I hope that is not to late:

I did a script that will try to install every package in the requirements.txt, if it can install the package it'll add the package name into a file named "existent.txt". So the list of the the existent packages will be in the "existent.txt".

while read line
do
    pip install $line;
    pip freeze | grep $line && echo $line >> existent.txt;
done < requirements.txt

you can put this in a file.sh to execute every time you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号