2

i'm making chess in python i'm having this error

this my code:

import chess.board

board=chess.Board()

board

full error:

Traceback (most recent call last):
  File "chess.py", line 1, in <module>
    import chess
  File "D:\Websites\repoting\chess.py", line 3, in <module>
    board=chess.Board()
AttributeError: module 'chess' has no attribute 'Board'
TheEagle
  • 5,808
  • 3
  • 11
  • 39
  • 1
    I don't have this module installed but the [docs](https://python-chess.readthedocs.io/en/latest/) say that the proper syntax is `import chess` then `board = chess.Board()` – bfris Oct 26 '21 at 19:24
  • 2
    Is the file you've saved your code in named `chess.py` by any chance? If so, do you get the same error if you change the name of this file? – Luke Woodward Oct 26 '21 at 20:11
  • if you post this answer i will select you post it – Patro Levis Oct 27 '21 at 05:18

1 Answers1

2

If you import chess you can use chess.Board(). But if you import chess.Board you could only use Board()from module chess. I hope this will help you and everyone who will read this answer.

LittleCoder
  • 391
  • 1
  • 13