kezper
kezper

Reputation: 91

'NameError: name 'fcntl' is not defined' when using urwid on windows

So I just installed Urwid and as a test tried running the Urwid equivalent of a basic print command, as given as an example on the Urwid website tutorial. I received an error message.

I tried running a different one of the examples and received a similar error message. The code looks like this:

import urwid

txt = urwid.Text(u"Hello World")
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill)
loop.run()

It should print 'Hello World' in the top left corner of the screen and then run until instructed to quit. Instead I get this error message:

Traceback (most recent call last):
  File "C:\Users\Rory Kranz\AppData\Local\atom\app-1.34.0\testingg", line 5, in <module>
    loop = urwid.MainLoop(fill)
  File "C:\Users\Rory Kranz\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urwid\main_loop.py", line 114, in __init__
    screen = raw_display.Screen()
  File "C:\Users\Rory Kranz\AppData\Local\Programs\Python\Python37-32\lib\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

Did something go wrong with the installation, or is there something else I need to install in order to get Urwid to work?

Upvotes: 5

Views: 6469

Answers (2)

max prehoda
max prehoda

Reputation: 34

The previous answer is outdated. Windows does not support the interface however installing the new Linux bash console will suffice.

Upvotes: 1

Paul Rooney
Paul Rooney

Reputation: 21609

If you want to use urwid, you will need to use it with cygwin (not sure of mingw supports it but it might be worth a try if that's your preference).

Windows does not natively support the fcntl interface and apparently it is not trivial to simulate it using win32 functions.

If you want to remain on windows without a unix emulation environment, you might try curses or python prompt toolkit. I can't be sure these are the best choices as I'm not clear on what exactly you are trying to do.

Some relevant links

Problem over windows platform
NameError: name 'fcntl' is not defined

Upvotes: 4

Related Questions