简体   繁体   中英

ImportError: attempted relative import with no known parent package?

Command:

python3 main.py file.dump

I get an error stating that:

File "main.py", line 3, in

from .Histogram import Histogram

ImportError: attempted relative import with no known parent package

I do not know where i am going wrong. I am in the same directory where the dump file, the Histogram.py file and the main.py file are placed.

For the .py files click on the link below:

https://github.com/riscv-newop/riscv-newop/tree/master/rvnewop

I am clueless. Where am I going wrong?

Why is the Histogram file not getting imported ?

since Histogram.py is in same folder as the main.py, You can simply write

from Histogram import Histogram 
obj = Histogram() 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM