This type of problem had me stuck last night for longer than it should have, so gonna throw the answer out there since I couldn't find this particular error on stack.
Say I have two files. my_function.py and variable.py
In my_function.py
from variable import a
def double(n):
return 2 * n
print(double(a))
In variable.py
from my_function import double
a = 4
I get an import error? How come? I had an empty init.py, they were in the same directory, and I had checked that I hadn't made a typo many times.
To help identify if you have this issue, your traceback should point to two different imports.
Traceback (most recent call last):
File "/Users/Owner/Documents/Stack Questions/my_function.py", line 1, in <module>
from variable import a
File "/Users/Owner/Documents/Stack Questions/variable.py", line 1, in
<module>
from my_function import double
File "/Users/Owner/Documents/Stack Questions/my_function.py", line 1, in <module>
from variable import a
ImportError: cannot import name 'a'