thomasahle / sunfish

Sunfish: a Python Chess Engine in 111 lines of code
https://www.chessprogramming.org/Sunfish
Other
2.91k stars 536 forks source link

chess.engine.EngineTerminatedError: engine process died unexpectedly (exit code: 127) #102

Open sugizo opened 1 year ago

sugizo commented 1 year ago
$ uname -a
Darwin sugizo.local 16.7.0 Darwin Kernel Version 16.7.0: Sun Jun  2 20:26:31 PDT 2019; root:xnu-3789.73.50~1/RELEASE_X86_64 x86_64

$ git clone https://github.com/thomasahle/sunfish
$ cd sunfish

$ tools/fancy.py -cmd ./sunfish.py
Traceback (most recent call last):
  File "/Users/sugizo/Downloads/sunfish/tools/fancy.py", line 284, in <module>
    asyncio.run(main())
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/sugizo/Downloads/sunfish/tools/fancy.py", line 234, in main
    engine = await load_engine_from_cmd(args.cmd, debug=args.debug)
  File "/Users/sugizo/Downloads/sunfish/tools/fancy.py", line 40, in load_engine_from_cmd
    _, engine = await chess.engine.popen_uci(cmd.split())
  File "/Users/sugizo/Downloads/test0/lib/python3.9/site-packages/chess/engine.py", line 2681, in popen_uci
    await protocol.initialize()
  File "/Users/sugizo/Downloads/test0/lib/python3.9/site-packages/chess/engine.py", line 1429, in initialize
    return await self.communicate(UciInitializeCommand)
  File "/Users/sugizo/Downloads/test0/lib/python3.9/site-packages/chess/engine.py", line 1094, in communicate
    return await command.result
chess.engine.EngineTerminatedError: engine process died unexpectedly (exit code: 127)
codethief commented 1 year ago

I'm seeing the same issue using Python 3.10.6 on Ubuntu 22.04.1.

I also tried pypy3.6-7.1.0 (listed at the bottom of the README) and got a type error when executing sunfish.py directly:

$ ./sunfish.py
Traceback (most recent call last):
  File "./sunfish.py", line 261, in <module>
    Entry = namedtuple("Entry", "lower upper", defaults=(-MATE_UPPER, MATE_UPPER))
TypeError: namedtuple() got an unexpected keyword argument 'defaults'

I think some clarification regarding which Python versions are supported is very much needed, especially since ./sunfish.py has a hashbang referring to PyPy3, while ./tools/fancy.py uses /usr/bin/env python3

sugizo commented 1 year ago
git clone https://github.com/thomasahle/sunfish
cd sunfish
python ./sunfish.py

result no error occured, just loading on terminal

expected result like on github readme

$ python ./sunfish.py
Playing against sunfish 2023.
Do you want to be white or black? black
  1 ♖ ♘ ♗ ♔ ♕ ♗ ♘ ♖
  2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
  3
  4
  5
  6
  7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
  8 ♜ ♞ ♝ ♚ ♛ ♝ ♞ ♜
    h g f e d c b a

Score: 23, nodes: 11752, nps: 13812, time: 0.9
 My move: d4
  1 ♖ ♘ ♗ ♔ ♕ ♗ ♘ ♖
  2 ♙ ♙ ♙ ♙   ♙ ♙ ♙
  3
  4         ♙
  5
  6
  7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
  8 ♜ ♞ ♝ ♚ ♛ ♝ ♞ ♜
    h g f e d c b a

Your move (e.g. c6 or g8h6): Nf6
codethief commented 1 year ago

@sugizo

result no error occured, just loading on terminal

What do you mean by "just loading"? Also, which Python version (on which OS) are you using?

thomasahle commented 1 year ago

Unfortunately sunfish.py can't use env, since it needs the -u argument added to python.

Regrading default values for namedtuple, I believe that requires Python 3.7.

yirod3721 commented 1 year ago

so what do we do now

codethief commented 1 year ago

@thomasahle Like @yirod3721 I'm not entirely sure what to make of your comment, given that I also tried to run Sunfish

using Python 3.10.6 on Ubuntu 22.04.1.

Maybe you could specify the Python versions Sunfish runs with fine, using e.g. a .tool-versions file? Alternatively, a devbox.json or, maybe even better, a Dockerfile?

sugizo commented 1 year ago
$ uname -a
Darwin sugizo.local 16.7.0 Darwin Kernel Version 16.7.0: Sun Jun  2 20:26:31 PDT 2019; root:xnu-3789.73.50~1/RELEASE_X86_64 x86_64
$ python -V
Python 3.9.13

just loading means no error occured, but no respond either,

loading is the loading animated on top of terminal is rounding

doctorvanmartin commented 1 year ago

Same problem here. I don't know how to fix it yet.

doctorvanmartin commented 1 year ago

Same problem here. I don't know how to fix it yet.

Solved.

sudo apt install pypy3

run as:

./tools/fancy.py -cmd ./sunfish.py

sugizo commented 1 year ago

not work too when tested on google colab steps

!apt install -y pypy3
!git clone https://github.com/thomasahle/sunfish

execute !cd sunfish && python ./sunfish.py

result same like tested on mac just loading means no error occured, but no respond either,

loading is the loading animated on top of terminal is rounding

execute !cd sunfish/tools/fancy.py -cmd ../sunfish.py

result /bin/bash: line 0: cd: too many arguments

codethief commented 1 year ago

@julupanter Which version of PyPy did you install exactly?

doctorvanmartin commented 1 year ago

@julupanter What version of PyPy did you install exactly?

The task was performed on a virtual machine that is no longer accessible, but at the time, it was the latest available. The virtual machine was running Ubuntu 22.10. I hope this information helps