[英]ImportError: I have made __init__.py file as well
I am having this error while I run the project:运行项目时出现此错误:
from .miner import Miner ImportError: attempted relative import with no known parent package from .miner import Miner ImportError: 没有已知父包的尝试相对导入
1--> init file, 2--> malicious miner.py which shoes the above-mentioned error. 1--> 初始化文件,2--> 出现上述错误的恶意 miner.py。
As it is mentioned in the picture I have a module name miner, there is also init to make share the proper module import, I have double-checked the files but somehow this error is presenting.正如图片中提到的,我有一个模块名称 miner,还有 init 来共享正确的模块导入,我仔细检查了文件,但不知何故出现了这个错误。 Can Someone please help me to solve this issue?
有人可以帮我解决这个问题吗?
This is the init file:这是初始化文件:
from .miner import Miner from .malicious_miner import MaliciousMiner从 .miner 导入矿工 从 .malicious_miner 导入 MaliciousMiner
while importing it doesn't show any error but when I run the file导入时没有显示任何错误,但是当我运行文件时
I strongly suggest you to use PyCharm.我强烈建议您使用 PyCharm。 Creating and importing files from the IDE really helps a lot in this type of problems, because it's not only creating an
init
.从 IDE 创建和导入文件确实有助于解决这类问题,因为它不仅仅是创建一个
init
。 I would like to help you further if using PyCharm won't solve the problem如果使用 PyCharm 不能解决问题,我想进一步帮助您
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.