Repository for reference --> https://github.com/SavSanta/bluinfo
So, Im trying to import a class BDROM
I made in the file called bluinfo.py
. (line 27)
By adding the line from bluinfo import BDROM
to the bluinfo-gui.py (line 8)
I am receiving ImportError: cannot import name 'BDROM'
I can not figure out how to get this badboy to work. Other posts state it may be related to PYTHONPATH (despite similar imports have been working in other parts of the program and all files are in the same directory).
I've tried to alter the import statement in the following ways to no success:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '__main__.bluinfo'; '__main__' is not a package
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: attempted relative import beyond top-level package
$dev:/tmp/blue/bluinfo$ touch __init__.py
$dev:/tmp/blue/bluinfo$ python3 bluinfo-gui.py
Traceback (most recent call last):
File "bluinfo-gui.py", line 8, in <module>
from bluinfo import BDROM
File "/tmp/blue/bluinfo/bluinfo.py", line 8, in <module>
import ts_scanner as ScanTask
File "/tmp/blue/bluinfo/ts_scanner.py", line 5, in <module>
import ts_streamtypeclass
File "/tmp/blue/bluinfo/ts_streamtypeclass.py", line 3, in <module>
from bluinfo import BDROM
ImportError: cannot import name 'BDROM'
Any ideas appreciated!
In your third attempt you have a circular import. Restructure your code to avoid that.
For example, you might be able to eliminate one of these imports, and you will get rid of the circular dependency.
File "/tmp/blue/bluinfo/bluinfo.py", line 8, in <module>
import ts_scanner as ScanTask
File "/tmp/blue/bluinfo/ts_streamtypeclass.py", line 3, in <module>
from bluinfo import BDROM
PS: Since you have a file called blueinfo.py
in a directory called blueinfo
, the statement import blueinfo
might mean either the package (directory) or the module (file). You could consider renaming the files inside the blueinfo directory to something more descriptive, to avoid this ambiguity.