gilesknap / mciwb

Minecraft Interactive world builder
Apache License 2.0
298 stars 6 forks source link

Unhandled exception error in event loop #75

Closed compX44 closed 1 year ago

compX44 commented 1 year ago

Hello. I'm trying to learn python with Minecraft using MCIWB.

For context, I'm using Docker, VSCode, Python 3.10.6, and iPython 8.11.0

When I typed in world.player.pos, I get the following error:

Unhandled exception in event loop: File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/input/vt100.py", line 173, in callback_wrapper callback() File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 698, in read_from_input self.key_processor.process_keys() File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 272, in process_keys self._process_coroutine.send(key_press) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 187, in _process self._call_handler(matches[-1], key_sequence=buffer[:]) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 322, in _call_handler handler.call(event) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 126, in call result = self.handler(event) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/IPython/terminal/shortcuts/init.py", line 374, in handle_return_or_newline_or_execute return newline_or_execute_outer(shell)(event) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/IPython/terminal/shortcuts/init.py", line 397, in newline_or_execute status, indent = shell.check_complete(check_text)

Exception 'NoneType' object has no attribute 'check_complete' Press ENTER to continue...

Unhandled exception in event loop: File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 698, in read_from_input self.key_processor.process_keys() File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 272, in process_keys self._process_coroutine.send(key_press) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 187, in _process self._call_handler(matches[-1], key_sequence=buffer[:]) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 322, in _call_handler handler.call(event) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 126, in call result = self.handler(event) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/IPython/terminal/shortcuts/init.py", line 374, in handle_return_or_newline_or_execute return newline_or_execute_outer(shell)(event) File "/home/useradd/my_world/.venv/lib/python3.10/site-packages/IPython/terminal/shortcuts/init.py", line 397, in newline_or_execute status, indent = shell.check_complete(check_text)

Exception 'NoneType' object has no attribute 'check_complete' Press ENTER to continue...

I've tried researching the problem, but have had no luck in terms of finding a solution. Is there a way to resolve this?

ulrikpedersen commented 1 year ago

Hi @gilesknap - I'm finally getting around to trying this out with my kids. I get a similar (same?) error when trying world.player.pos - in fact I get the same or similar error every time I hit enter or tab to autocomplete...

(.venv) mini:python-minecraft ulrik$ mciwb shell --player AlbaDancer
INFO:   Connected to localhost on 20100
INFO:   Monitoring player AlbaDancer enabled for sign commands
INFO:   ######### Starting Interactive Session ##########

Python 3.10.9 (main, Dec 15 2022, 10:44:50) [Clang 14.0.0 (clang-1400.0.29.202)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.11.0 -- An enhanced Interactive Python. Type '?' for help.

Unhandled exception in event loop:
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/prompt_toolkit/input/vt100.py", line 173, in callback_wrapper
    callback()
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 698, in read_from_input
    self.key_processor.process_keys()
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 272, in process_keys
    self._process_coroutine.send(key_press)
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 187, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 322, in _call_handler
    handler.call(event)
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 126, in call
    result = self.handler(event)
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/IPython/terminal/shortcuts/__init__.py", line 374, in handle_return_or_newline_or_execute
    return newline_or_execute_outer(shell)(event)
  File "/Users/ulrik/code/python-minecraft/.venv/lib/python3.10/site-packages/IPython/terminal/shortcuts/__init__.py", line 397, in newline_or_execute
    status, indent = shell.check_complete(check_text)

Exception 'NoneType' object has no attribute 'check_complete'
Press ENTER to continue...
gilesknap commented 1 year ago

@compX44 @ulrikpedersen thanks for the interest!

The issue was related to the latest version of ipython and is now fixed in main. Unfortunately something is broken with publishing to pypi so if you are happy to clone the main branch and use 'pip install .' then go ahead and give it a go.

I'll try to get the pypi release done soon, but really want to adopt the latest skeleton project which changes the details of this part of the CI quite a bit. That is a bit of a bigger job so might not be done this weekend.

gilesknap commented 1 year ago

That was easier than expected.

The new release is 0.8.4. https://pypi.org/project/mciwb/

@compX44 @ulrikpedersen Please report back to let me know if this fixes the issue for you.

ulrikpedersen commented 1 year ago

Thanks Giles! I stopped the server and updated the venv with pip install --upgrade mciwb restart server and shell and voila it works! That's pro support 👍 😄

gilesknap commented 1 year ago

Thanks Ulrik. Closing.

I'm looking forward to some suggestions for the learning python tutorials from you!

compX44 commented 1 year ago

Hello. I apologize for the late response. After updating the mciwb package, I too got the code to work. Thank you so much for taking the time to look into this issue. I'm excited to learn more about python with this project.