Python 2.7 Cx_Freeze:ImportError:没有名为__startup__的模块

时间:2022-01-29 18:02:30

I am trying to compile a hello world program in Python into a stand-alone binary/package on Linux using cx_Freeze. When cx_Freeze is run, it completes without an error but when I attempt to run the generated executable, I am given the error:

我正在尝试使用cx_Freeze将Python中的hello world程序编译成Linux上的独立二进制/包。当cx_Freeze运行时,它完成没有错误但是当我尝试运行生成的可执行文件时,我收到错误:

ImportError: No module named __startup__

My setup.py file is:

我的setup.py文件是:

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

base = 'Console'

executables = [
    Executable('test.py', base=base)
]

setup(name='test',
      version = '1.0',
      description = '',
      options = dict(build_exe = buildOptions),
      executables = executables)

And it is run as such:

它运行如下:

python setup.py build

I am confused as to why this is happening. If the ImportError was for a library, I would understand - but __startup__ is unfamiliar to me.

我很困惑为什么会这样。如果ImportError是一个库,我会理解 - 但是__startup__对我来说并不熟悉。

Thanks.

2 个解决方案

#1


4  

I had the same problem with cx_Freeze 5.0.0. I was able to fix this after downgrading cx_freeze to 4.3.4. Other versions may also work.

我遇到了与cx_Freeze 5.0.0相同的问题。在将cx_freeze降级到4.3.4之后,我能够解决这个问题。其他版本也可以使用。

#2


-2  

I encountered the same problem.For your goals, you can try pinstaller.'hello world' accurately compile. But the question remains open, how to conquer this bug

我遇到了同样的问题。为了你的目标,你可以尝试pinstaller.'hello world'准确编译。但问题仍然存在,如何克服这个错误

#1


4  

I had the same problem with cx_Freeze 5.0.0. I was able to fix this after downgrading cx_freeze to 4.3.4. Other versions may also work.

我遇到了与cx_Freeze 5.0.0相同的问题。在将cx_freeze降级到4.3.4之后,我能够解决这个问题。其他版本也可以使用。

#2


-2  

I encountered the same problem.For your goals, you can try pinstaller.'hello world' accurately compile. But the question remains open, how to conquer this bug

我遇到了同样的问题。为了你的目标,你可以尝试pinstaller.'hello world'准确编译。但问题仍然存在,如何克服这个错误