Assume I have the following file structure:
A/
__init__.py
B.py
Inside __init.py__
I have the following:
__init__.py/
import numpy as np
import pandas as pd
Then inside the B.py I have the following:
B.py/
from A import np
print(np.linspace(0,10,10))
However, this code produces an error that no module named A
. If for now, we do not consider the circular import problem which is not the case here. How can I import from
__init.py__
Since otherwise, all the imports I have in it will be useless. I recall a while ago I could run a code like above with no problem but now this is a problem.
I can just add the path to package A to sys.path
but then every time I should run the command and is not even scalable or practical.
Does anyone why python is complaining and how I can import what I have in init.py?