Closed Bstylestuff closed 5 years ago
Hi, thanks for reporting. It looks like some output is missing at the start of the stacktrace (in particular the message and type of the exception). Can you please check and include that?
Edit: Also a guess: If this is a FileNotFoundError, is stockfish.exe in your system PATH
or in the working directory?
Here is the stacktrace:
Traceback (most recent call last): File "E:/Chess/Software/testing.py", line 4, in <module> engine = chess.engine.SimpleEngine.popen_uci("stockfish") File "E:\Chess\Software\chess\engine.py", line 2227, in popen_uci return cls.popen(UciProtocol, command, timeout=timeout, debug=debug, setpgrp=setpgrp, **popen_args) File "E:\Chess\Software\chess\engine.py", line 2219, in popen return run_in_background(background, debug=debug) File "E:\Chess\Software\chess\engine.py", line 193, in run_in_background return future.result() File "D:\Users\TekAdvice\Anaconda3\lib\concurrent\futures\_base.py", line 432, in result return self.__get_result() File "D:\Users\TekAdvice\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result raise self._exception File "E:\Chess\Software\chess\engine.py", line 172, in background loop.run_until_complete(coroutine(future)) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\base_events.py", line 484, in run_until_complete return future.result() File "E:\Chess\Software\chess\engine.py", line 2211, in background transport, protocol = yield from asyncio.wait_for(Protocol.popen(command, setpgrp=setpgrp, **popen_args), timeout) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\tasks.py", line 358, in wait_for return fut.result() File "E:\Chess\Software\chess\engine.py", line 803, in popen transport, protocol = yield from loop.subprocess_exec(cls, *command, **popen_args) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\base_events.py", line 1211, in subprocess_exec bufsize, **kwargs) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\windows_events.py", line 378, in _make_subprocess_transport **kwargs) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\base_subprocess.py", line 39, in __init__ stderr=stderr, bufsize=bufsize, **kwargs) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\windows_events.py", line 762, in _start bufsize=bufsize, **kwargs) File "D:\Users\TekAdvice\Anaconda3\lib\asyncio\windows_utils.py", line 205, in __init__ stderr=stderr_wfd, **kwds) File "D:\Users\TekAdvice\Anaconda3\lib\subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "D:\Users\TekAdvice\Anaconda3\lib\subprocess.py", line 1017, in _execute_child startupinfo)FileNotFoundError: [WinError 2] The system cannot find the file specified
And this is what testing.py is:
import chess
import chess.engine
engine = chess.engine.SimpleEngine.popen_uci("stockfish")
board = chess.Board("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
while not board.is_game_over():
result = engine.play(board, chess.engine.Limit(time=0.100))
board.push(result.move)
engine.quit()
On Saturday, January 19, 2019, 4:04:37 PM GMT+2, Niklas Fiekas <notifications@github.com> wrote:
Hi, thanks for reporting. It looks like some output is missing at the start of the stacktrace. Can you please check and include that?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
FileNotFoundError: [WinError 2] The system cannot find the file specified
would indicate that stockfish is not in your system PATH
or in the working directory. Maybe try specifying the absolute path to stockfish.exe?
I tried to send it to the stockfish.py file in both the file I sent you earlier and in the engine's uci.py. I tried both with and without the ".py" extension. Same issue On Saturday, January 19, 2019, 5:22:24 PM GMT+2, Niklas Fiekas notifications@github.com wrote:
FileNotFoundError: [WinError 2] The system cannot find the file specified would indicate that stockfish is not in your system PATH or in the working directory. Maybe try specifying the absolute path to stockfish.exe?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Sorry, maybe we're talking past each other. This will try to open stockfish.exe
from the system PATH (or maybe from the current working directory - not sure if that's included on Windows).
engine = chess.engine.SimpleEngine.popen_uci("stockfish.exe") # appended .exe for clarity
You can also try an absolute or relative path:
engine = chess.engine.SimpleEngine.popen_uci(r"C:\path\to\stockfish.exe")
You can also try running stockfish
on the Windows Command Prompt to test things.
I tried both with and without the ".py" extension.
I am confused. Is the executable called stockfish.py
? Are you trying to use this?
Originally I tried the python, but then got the windows executable from their website, it works. Still can't launch due to pipe errors, but will look into it later. Thank you!
Sent from Yahoo Mail on Android
On Sat, 19 Jan 2019 at 17:44, Niklas Fiekasnotifications@github.com wrote:
Sorry, maybe we're talking past each other. This will try to open stockfish.exe from the system PATH (or maybe from the current working directory - not sure if that's included on Windows).
engine = chess.engine.SimpleEngine.popen_uci("stockfish.exe") # appended .exe for clarity
You can also try an absolute or relative path: engine = chess.engine.SimpleEngine.popen_uci(r"C:\path\to\stockfish.exe")
You can also try running stockfish on the Windows Command Prompt to test things.
I tried both with and without the ".py" extension.
I am confused. Is the executable called stockfish.py? Are you trying to use this?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Cool, sounds like progress :)
For BrokenPipeError it could be helpful to check if the engine sent anything before it died (https://python-chess.readthedocs.io/en/latest/engine.html#logging).
The engine after my understanding was unable to send anything before it died.
Exception in callback EngineProtocol.pipe_data_received(1, b'id name Sto...\r\nuciok\r\n')
handle: <Handle EngineProtocol.pipe_data_received(1, b'id name Sto...\r\nuciok\r\n')>
Traceback (most recent call last):
File "E:\Univ\Python\lib\asyncio\events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "E:\Univ\Python\lib\site-packages\chess\engine.py", line 607, in pipe_data_received
self._line_received(line)
File "E:\Univ\Python\lib\site-packages\chess\engine.py", line 620, in _line_received
self.command._line_received(self, line)
File "E:\Univ\Python\lib\site-packages\chess\engine.py", line 872, in _line_received
self.line_received(engine, line)
File "E:\Univ\Python\lib\site-packages\chess\engine.py", line 917, in line_received
self._option(engine, line.split(" ", 1)[1])
File "E:\Univ\Python\lib\site-packages\chess\engine.py", line 979, in _option
option = Option(name, type, without_default.parse(default), min, max, var)
File "E:\Univ\Python\lib\site-packages\chess\engine.py", line 233, in parse
raise EngineError("invalid line-break in string option {!r}".format(self.name))
chess.engine.EngineError: invalid line-break in string option 'Debug Log File'
The input it gets from the stockfish ai through the pipe is:
Stockfish 8 64 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
id name Stockfish 8 64
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott
option name Debug Log File type string default
As you can see it's Stockfish 8, I tried using another version, thought the bug might be because of deprecation of some sort. It gives the same output with Stockfish 10 too I think that the error here is that it cannot parse the Debug Log File name because it finds an \r inside of it. Any hints on how this worked before?
Thanks, that helped a lot. The new chess.engine
simply did not properly handle Windows-style line endings. Added an automated test to prevent this in the future and released a fixed v0.25.1.
It works like a charm. Thanks!
When I attempt to run it in windows, I get an error:
Any suggestions?