Python 3.5.0中没有名为/父模块未加载的模块

2024-09-28 03:12:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我的包裹有这样的结构:

/code_trou
    __init__.py
    Main.py
    Menu.py
    /postprocessing
    /preprocessing
    Mesh.py
    Point.py
    /processing
        FDM.py
    /tools
        dllmrg.py
        errormrg.py
        /__pycache_
           errormrg.cpython-35.pyc

执行Main.py时:

^{pr2}$

我有这个错误:"No module named 'tools'"

执行Point.py时也是一样的:

from tools.dllmrg import *

对于Point.py我尝试了the Intra-package References described in the doc,但似乎没有起作用:我在执行Point.py时得到了错误"Parent module '' not loaded, cannot perform relative import",取而代之的是:

from ..tools.dllmrg import *

Tags: thefrompyimportinitmain错误code
1条回答
网友
1楼 · 发布于 2024-09-28 03:12:31

使目录成为Python包的原因是__init__.py文件的存在。您的toolsprocessing目录中没有这样的文件,因此Python不会将它们识别为包。在

https://docs.python.org/3/tutorial/modules.html#packages

相关问题 更多 >

    热门问题