I'm trying to export a python-chess game to a pgn file. The documentation recommends -
import chess
.
.
chessBoard = chess.Board()
.
.
#Play the game and when over do below
game = chess.pgn.Game.from_board(chessBoard)
with open('output.pgn', 'a') as the_file:
print(game, file=the_file, end="\n\n")
But the chess.pgn.Game.from_board(chessBoard)
line throws the below error -
AttributeError: module 'chess' has no attribute 'pgn'
pgn
shows up in intellisense as well when I type chess.
so the editor is also able to see that there is a pgn
in chess
. This is python 3.x running in VS2015 on windows 10.
What could be causing it?
To use the pgn
module you'd also have to do import chess.pgn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With