【问题标题】:cx_Freeze + curses: 'NoneType' object has no attribute 'fileno'cx_Freeze + curses: 'NoneType' 对象没有属性 'fileno'
【发布时间】:2019-07-22 05:39:07
【问题描述】:

我已经从以下 python 脚本使用cx_Freeze 实用程序生成了一个exe 文件:

from curses import wrapper

def main(stdscr):
    pass

wrapper(main)

但是当我运行它时,它给了我一个错误:

AttributeError: 'NoneType' object has no attribute 'fileno'

完全错误:

问题是当我从脚本中排除 wrapper(main) 时,exe 可以正常工作。

【问题讨论】:

  • 听起来像是 cx_freeze 的限制(fileno 是标准的 C 运行时函数)。
  • 能否分享您的安装脚本?您在哪个 (Windows) 平台上工作,您是如何让 curses 在其上工作的(标准 Python 安装中包含的 curses 模块在 Windows 7 上不起作用)。

标签: python cx-freeze curses


【解决方案1】:

我可以在 Windows 7 上使用 python 3.6 和 cx_Freeze 5.1.1 从您的 curses_example.py python 脚本生成一个工作可执行文件,并使用以下设置脚本:

from cx_Freeze import setup, Executable

executables = [Executable('curses_example.py')]

setup(name='curses_example',
      version='0.1',
      description='Sample cx_Freeze script',
      executables=executables)

要让curses 工作,我首先需要安装windows-curses 使用

pip install windows-curses

根据ImportError: No module named '_curses' when trying to import blessings 的提示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    相关资源
    最近更新 更多