看起来你的 mf3.py 文件中正在进行 超出顶层的导入操作。
假设你的项目结构如下:
folder/
main.py
mod/
__init__.py
components/
__init__.py
expander.py
language_id.py
utilities/
__init__.py
functions.py
首先确保
main.py refers to the subpackages as:
from mod.components.expander import * from mod.utilities.functions import *
expander.py and language_id.py have access to functions.py with:
from ..utilities.functions import *
为你的setup.py添加选项
你也可以使用更多py2exe选项,以便导入项目所需的所有模块和包。例如:
# setup.py
from distutils.core import setup
import py2exe
setup(console=["script.py"],
options={
"py2exe":{
"optimize": 2,
"includes": ["mf1.py", "mf2.py", "mf3.py"], # List of all the modules you want to import
"packages": ["package1"] # List of the package you want to make sure that will be imported
}
}
)