Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 28 lines (22 sloc) 794 Bytes
#!/usr/bin/env python3
""" Find missing modules """
import sys, re, importlib, subprocess
def addto(imports, what):
what = what.split('.')[0]
if what not in imports:
except ModuleNotFoundError:
info = sys.exc_info()[1]
imports = set()
cmd = r"grep -h 'import ' *.py | sed -e 's/#.*//' -e 's/ as .*//' -e 's/,/ /g'"
ans =, shell=True, capture_output=True, text=True).stdout.split('\n')
for line in ans:
line = line.strip()
if line.startswith('from'):
addto(imports, line.split()[1])
elif line.startswith('import'):
for mod in line.split()[1:]:
addto(imports, mod)
print('\n'.join(sorted(imports, key=str.lower)))
You can’t perform that action at this time.