Python 3.5.0中未加载名为/Parent的模块
我的包有以下结构:Python 3.5.0中未加载名为/Parent的模块,python,python-3.x,Python,Python 3.x,我的包有以下结构: /code_trou __init__.py Main.py Menu.py /postprocessing /preprocessing Mesh.py Point.py /processing FDM.py /tools dllmrg.py errormrg.py /__pycache_ errormrg.cpyth
/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
时:
from tools.errormrg import *
from tools.dllmrg import *
我有以下错误:“没有名为‘工具’的模块”
当我使用以下命令执行Point.py
时也是如此:
from tools.errormrg import *
from tools.dllmrg import *
对于Point.py
我尝试了,但似乎不起作用:我在执行Point.py
时遇到错误“父模块“”未加载,无法执行相对导入”
,改为:
from ..tools.dllmrg import *
使目录成为Python包的原因是存在一个
\uuuu init\uuuuu.py
文件。您的工具
和处理
目录中没有此类文件,因此Python不会将它们识别为包
您需要在
/tools
中使用\uuuu init\uuuuuuuuuuupy
,以使该模块也成为一个模块(其他子模块也是如此)。