我有多个python文件,其中包含我在其中创建的模块。文件相互依赖于模块。

目前,我在一个文件夹中拥有所有这些

main.py  
readfile.py  
pronunciation.py  
meaning.py  
classes.py
.

我使用的唯一模块是内置随机(我不确定如何添加)。这是我当前的代码

from cx_Freeze import setup,Executable

includefiles = []
includes = ['classes.py','pronunciation.py','readfile.py','meaning.py']
excludes = []
packages = []

setup(name = 'Revision',
      version = '0.1',
      description = 'Revision program for studying',
      author = '',
      author_email = '',
      options = {'build_exe': {'includes': includes,'excludes':excludes,'packages':packages,'include_files':includefiles}},
      executables = [Executable('main.py')])
.

从此,我得到一个importError,说模块类。没有存在(它是在意义上导入的),我如何解决这个问题?此外,我担心CX_Freeze可能不会随机导入。

在窗户上,btw。

有帮助吗?

解决方案

尝试替换

includes = ['classes.py','pronunciation.py','readfile.py','meaning.py']
.

includes = ['classes','pronunciation','readfile','meaning']
.

此列表包含在构建期间要导入的模块。 在Python中,我们没有在导入中指定* .py扩展。

btw。在Python的条款中* .py files=模块,它是相同的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top