0

Team: need clarification and hints please. thanks.

My requirement is to load a test module only if pip install succeeds so install is working fine but import is failing. any hint?

def export_prereq(self):
    req1 = subprocess.run(['pip install test_mod'], shell=True)
    if req1.returncode == 0:
        print("pip install succeeded")
        try:
            import test_mod
        except ImportError:
            print("'import test_mod' failed")
    else:
        print("pip install failed")
    return self

output


Requirement already satisfied: test_mod in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (0.0.1.post2)
pip install succeeded
'import test_mod' failed
AhmFM
  • 1,552
  • 3
  • 23
  • 53
  • i think my question is duplicate of https://stackoverflow.com/questions/17234762/how-to-install-and-import-python-modules-at-runtime – AhmFM Sep 13 '22 at 22:14

0 Answers0