0

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

  • main.py has import Cus_Scripts.script1
  • script1.py has from script2 import classA

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

Asocia
  • 5,935
  • 2
  • 21
  • 46
Ryan Higgins
  • 11
  • 1
  • 3

1 Answers1

1

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 

Ryan Higgins
  • 11
  • 1
  • 3