2017-03-07 16 views
2

私はpython-chessゲームをpgnファイルにエクスポートしようとしています。 documentationは推奨しています -python-chess - AttributeError:モジュール 'chess'に属性 'pgn'がありません

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") 

しかしchess.pgn.Game.from_board(chessBoard)ラインは、以下のエラーがスローされます -

AttributeError: module 'chess' has no attribute 'pgn'

pgnを私はchess.を入力するときにもインテリセンスに表示さそうエディタも存在することを確認することができますpgnchess。これは、Windows 10上のVS2015で実行されているPython 3.xです。

何が原因なのでしょうか?

+0

を行う必要があるだろうpgnモジュールを使用するには、私は、エラーの同じ種類を持っていた: 'はAttributeError:「モジュール」オブジェクトには属性が「はいそれはそれを固定 – Purplejacket

答えて

5

あなたもimport chess.pgn

+0

おかげで、svg''ていません。 – Achilles

関連する問題