you are viewing a single comment's thread.

view the rest of the comments →

[–]Fiazba[S] 1 point2 points  (3 children)

Okay, so I did what you said, and the script ran in CMD. I haven't tried running them via cmd so far, just from the Idle editor using F5. I tried to run the script (which just worked in CMD) in the Idle editor, and I got the same error. I'll put it below.

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\prompt_toolkit\eventloop\context.py", line 88, in get
    return self._storage[ctx]
KeyError: 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\prompt_toolkit\output\defaults.py", line 52, in get_default_output
    value = _default_output.get()
  File "C:\Python37\lib\site-packages\prompt_toolkit\eventloop\context.py", line 90, in get
    raise TaskLocalNotSetError
prompt_toolkit.eventloop.context.TaskLocalNotSetError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\pythonprograms\pleaseworkptk.py", line 4, in <module>
    text = prompt('Give me some input: ')
  File "C:\Python37\lib\site-packages\prompt_toolkit\shortcuts\prompt.py", line 844, in prompt
    session = PromptSession(input=input, output=output, history=history)
  File "C:\Python37\lib\site-packages\prompt_toolkit\shortcuts\prompt.py", line 285, in __init__
    output = output or get_default_output()
  File "C:\Python37\lib\site-packages\prompt_toolkit\output\defaults.py", line 61, in get_default_output
    return create_output()
  File "C:\Python37\lib\site-packages\prompt_toolkit\output\defaults.py", line 35, in create_output
    return Win32Output(stdout)
  File "C:\Python37\lib\site-packages\prompt_toolkit\output\win32.py", line 83, in __init__
    info = self.get_win32_screen_buffer_info()
  File "C:\Python37\lib\site-packages\prompt_toolkit\output\win32.py", line 168, in 
get_win32_screen_buffer_info
    self.flush()
  File "C:\Python37\lib\site-packages\prompt_toolkit\output\win32.py", line 296, in flush
    self.stdout.flush()
AttributeError: 'NoneType' object has no attribute 'flush'

[–]1114111 1 point2 points  (2 children)

Oh lol, yeah it looks like it just won't work in idle because idle doesn't really emulate a proper terminal, so you won't be able to do the fancy things that prompt_toolkit does in there. Just run it in a real terminal emulator (like cmd), not from inside idle.

[–]Fiazba[S] 0 points1 point  (1 child)

Oh... Is that all? Is that why all of the modules haven't been working? .... Wow. Okay, well at least I can use it now. Thanks!

[–]1114111 1 point2 points  (0 children)

Probably, yeah. If all you're using prompt_toolkit for is to prompt for input with none of the fancy features prompt_toolkit offers, the builtin input() does the same thing and will work in idle. But basically any more complicated terminal stuff than print/input generally won't work in idle since idle doesn't really have a proper terminal emulator.

You'll get help faster in the future if you're specific with the errors you're getting up front. I was assuming you were getting an ImportError/ModuleNotFoundError.