简体   繁体   English

Python导入ModuleNotFoundError:没有名为“模型”的模块

[英]Python import ModuleNotFoundError: No module named 'model'

I have problem with this hmm code that I have cloned 我克隆的这个hmm代码有问题

When I go for 当我去

python testing/example.py 
Traceback (most recent call last):
  File "testing/example.py", line 2, in <module>
    from model import sensors, general_inf
ModuleNotFoundError: No module named 'model'

Why is import not working? 为什么导入无效? I could change the original code but I do not understand the error.Three lines from example.py 我可以更改原始代码,但我不理解错误。example.py中的三行

from model import sensors, general_inf
from testing import viz, synth
from numpy import shape

I tested the code on my computer, after moving the file example.py out of the testing directory , it worked(as the picture shows). 将文件example.pytesting目录中移出后,我在计算机上进行了代码testing ,如图所示。
在此处输入图片说明
Besides, I think if you add the absolute path of model into sys.path , it may work as well.(not tested) 此外,我认为如果将model的绝对路径添加到sys.path ,它也可能会正常工作。(未测试)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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