toot icon indicating copy to clipboard operation
toot copied to clipboard

NameError: name 'fcntl' is not defined

Open mikwee opened this issue 2 years ago • 6 comments

When I try to open the TUI, I get this error:

Traceback (most recent call last):
  File "C:\Users\mikwee\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\mikwee\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\Scripts\toot.exe\__main__.py", line 7, in <module>
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\console.py", line 560, in main
    run_command(app, user, command_name, args)
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\console.py", line 542, in run_command
    return fn(app, user, parsed_args)
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\commands.py", line 347, in tui
    TUI.create(app, user).run()
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\toot\tui\app.py", line 78, in create
    loop = urwid.MainLoop(
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\urwid\main_loop.py", line 115, in __init__
    screen = raw_display.Screen()
  File "C:\Users\mikwee\AppData\Roaming\Python\Python310\site-packages\urwid\raw_display.py", line 92, in __init__
    fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
NameError: name 'fcntl' is not defined

What's happening?

mikwee avatar May 31 '22 15:05 mikwee

fcntl is not supported on windows. If you want to run toot tui you can try using WSL, although it might be overkill if that's the only thing you're using it for. It might also work in cygwin, not sure, don't have a windows box to test.

ihabunek avatar May 31 '22 16:05 ihabunek

Is there no file handling library in Python that abstracts between platforms?

igalic avatar May 31 '22 21:05 igalic

fnctl is used by urwid, which is used to build the TUI. I haven't really looked into how it could be made to work on windows.

ihabunek avatar May 31 '22 21:05 ihabunek

I think it would require switching from urwid to a library that supports Windows terminals as well, like asciimatics, blessed, prompt_toolkit, or textual.

If that's a direction you're willing to go, I'd be happy to work on it. I'd like to be able to use the TUI on Windows without resorting to WSL.

nausicaa-rose avatar Nov 20 '22 17:11 nausicaa-rose

@wtee It is something I have considered. I tried blessed and prompt_toolkit and wasn't enamored. I liked the look of textual but it's very early in development, and needs a bit more time to mature. I'll probably be making incremental improvements to urwid variant for a little while longer. I'll check out asciimatics too, since I haven't looked at it yet.

ihabunek avatar Nov 21 '22 08:11 ihabunek

version 0.42.0 works like a charm in cygwin on Windows 10. Installing with ' python -m pip install toot==0.42' hung installing urwid, so I just installed urwid separately.

If I knew it was going to be this easy with cygwin, I would have installed it whenI forked it last year, 60 commits ago.

drbean avatar Apr 01 '24 07:04 drbean