Python Chess调用Stockfish遇WinError 5权限拒绝问题求助
Python Chess调用Stockfish引擎时遭遇权限拒绝错误(WinError 5)
使用Python Chess库调用Stockfish引擎时,代码第65行初始化engine变量时触发权限拒绝错误。已尝试以下操作但问题未解决:
- 以管理员身份运行代码
- 更换Stockfish文件存放位置
- 在路径后添加
.exe后缀
相关代码片段
def get_most_recent_game(username): data = get_player_game_archives(username).json url = data['archives'][-1] games = requests.get(url).json() game = games['games'][-1] # 获取对局类型(快棋等...) gametype = game['time_class'] print('PLAYERS -', gametype) # 黑方数据 black = game['black'] blackusername = black['username'] blackrating = black['rating'] blackresult = black['result'] print('Black) Username:', blackusername, ' | elo:', blackrating, ' | result:', blackresult) # 白方数据 white = game['white'] whiteusername = white['username'] whiterating = white['rating'] whiteresult = white['result'] print('White) Username:', whiteusername, ' | elo:', whiterating, ' | result:', whiteresult) # 获取对局走法 gamepgn = game['pgn'] pgnstring = str(gamepgn) pgn = StringIO(pgnstring) pgngame = chess.pgn.read_game(pgn) pgnmoves = pgngame.mainline_moves() board = pgngame.board() count = 0 print("MOVES") for move in pgnmoves: count += 1 print(board.san(move)) board1 = board.push(move) engine = chess.engine.SimpleEngine.popen_uci(r"C:\Users\georg\VScode projects\chessanylizer\stockfish_15.1_win_x64_avx2") info = engine.analyse(board1, chess.engine.Limit(depth=20)) print("Score:", info["score"]) # printer.pprint(game) get_most_recent_game("gothamchess")
报错信息
Traceback (most recent call last): File "c:\Users\georg\VScode projects\chessanylizer\chessanylizer.py", line 72, in <module> get_most_recent_game("gothamchess") File "c:\Users\georg\VScode projects\chessanylizer\chessanylizer.py", line 65, in get_most_recent_game engine = chess.engine.SimpleEngine.popen_uci(r"C:\Users\georg\VScode projects\chessanylizer\stockfish_15.1_win_x64_avx2") PermissionError: [WinError 5] Access is denied
内容的提问来源于stack exchange,提问作者Gekaz
相关产品推荐
相关产品推荐

