Ryan Higgins
Ryan Higgins

Reputation: 11

Getting a ModuleNotFoundError when trying to load a Python Module and all seems ok

I have a tree structure

 - My_app    
   - __init__.py
   - main.py
   - Cus_Scripts  
      - __init__.py
      - script1.py
      - script2.py - classA

I am running like this

in script1 I get a ModuleNotFoundError saying it can't find script2. I am using VSC.

Upvotes: 0

Views: 146

Answers (1)

Ryan Higgins
Ryan Higgins

Reputation: 11

I fixed this by adding this to every file.


#Custom Lib
sys.path.insert(1, os.getcwd())

This allowed me to access anypart of the program with


from My_App.script2 import classA
import My_App.script1 

Upvotes: 1

Related Questions