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]
#get game type(rapid...)
gametype = game['time_class']
print('PLAYERS -', gametype)
#blacks stats
black = game['black']
blackusername = black['username']
blackrating = black['rating']
blackresult = black['result']
print('Black) Username:', blackusername, ' | elo:', blackrating, ' | result:', blackresult)
#white stats
white = game['white']
whiteusername = white['username']
whiterating = white['rating']
whiteresult = white['result']
print('White) Username:', whiteusername, ' | elo:', whiterating, ' | result:', whiteresult)
#get game moves
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")
Ignore most of the code ,the error is in the 65 line on the engine variable,i tried running the code as administrator and i have also tried changing the location of the stockfish,i have also tried putting .exe in the end but i keep running on this access denied error.
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
You have the wrong path, you need to point to the .exe file like this: