I want to detect imported packages in one python module. But this will be done on another python module.
I couldn't find a way to do apart from opening the module I want to get imported package names and find the "import" string, use split with space and get the name of the package.
with open(path, 'r') as file:
for line in file:
if "import" in line:
seperate = line.split(" ")
if seperate[0] == "import":
print(seperate[1].rstrip())
Is there any advice?