I am trying to access custom package modules, but getting "module not found" error. Under the directory `
└── C:\PythonProg
├── Test.py
└── PackageTest
├── __init__.py
├── mod1.py
└── mod2.py
In __init__.py
, I have:
import mod1
import mod2
In mod1.py
:
def mult(x,y):
print(x*y)
In mod2.py
:
def add(x,y):
print(x,y)
In Test.py
:
import PackageTest as pt
pt.mod1.add(2,3)
pt.mod2.mult(1,2)
When executing Test.py
, why is the error popping up again, saying "No Module Named mod1
"?
I have tried many times, still facing same error.
Error :
Traceback (most recent call last):
File "c:\PythonProg\PackageTest\__init__.py", line 1, in <module>
import mod1
ModuleNotFoundError: No module named 'mod1'