Assume I have the following file structure:
Package/
__init__.py
A.py
B.py
Inside __init__.py
I have the following:
__init__.py/
import numpy as np
import pandas as pd
Then I issue the following in the A.py script:
A.py/
from Package import *
However, I receive an error message that no module name Package is defined.
ModuleNotFoundError: No module named Package
I thought from Package import *
means running everything in the __init__.py
.
I can run the A.py content and use the init import from B.py as I expected.(using from Package import *
)
I am using VSCode and Anaconda and my OS is Windows 10.
I can append the project folder every time to my PythonPath using the following commands:
sys.path.append("Path to the Package")
But I do not want to run this piece of code every time.
Can anyone explain what is the problem? Is this a new problem in Python since I do not recall having such issues in the past?