添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

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

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.