This looks very much like XY problem. Would you elaborate on what the ultimate goal is? "check if the modules python files exist or not" is not very clear.
e.g. if you want to check that trying to import module will not raise error - there is idiomatic way to do it using try/except
if you want to import module by using name string - look at importlib
e.g. if you want to check that trying to import module will not raise error - there is idiomatic way to do it using try/except
if you want to import module by using name string - look at importlib
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs