Search code examples
pythoncx-freezecurses

cx_Freeze + curses: 'NoneType' object has no attribute 'fileno'


I've generated an exe file with the cx_Freeze utility from the following python script:

from curses import wrapper

def main(stdscr):
    pass

wrapper(main)

But when I'm running it, it gives me an error:

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

Full error:

Error message

The thing is that the exe works without errors when I'm excluding wrapper(main) from the script.


Solution

  • I can produce a working executable from your curses_example.py python script using python 3.6 and cx_Freeze 5.1.1 on Windows 7 with the following setup script:

    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)
    

    To get curses to work, I first needed to install windows-curses using

    pip install windows-curses
    

    following a hint from ImportError: No module named '_curses' when trying to import blessings.