I have a requirements.txt file with a list of packages that are required for my virtual environment. Is it possible to find out whether all the packages mention
If requirements.txt is like :
django
oursql
sys
notexistingmodule
Then the following script will tell you which modules are missing :
#!/usr/bin/python3
fname = 'requirements.txt'
with open(fname, 'r', encoding='utf-8') as fhd:
for line in fhd:
try:
exec("import " + line)
except:
print("[ERROR] Missing module:", line)
This would print :
[ERROR] Missing module: notexistingmodule