0

I'm probably overlooking something obvious, but, that's what StackOverflow is for. I am new to Python and coding in it.

I installed the module 'chess' via "pip3 install chess" - it is installed and when I run the command now it gives me the following:

    Requirement already satisfied: chess in /home/XusernameX/.local/lib/python3.8/site-packages (1.4.0)

The code I have in chess.py is the following (as pulled from this page: https://andreasstckl.medium.com/writing-a-chess-program-in-one-day-30daff4610ec):

import chess
import chess.svg

from IPython.display import SVG

board = chess.Board()
SVG(chess.svg.board(board=board,size=400))

when I run it, I get the following error:

Traceback (most recent call last):
  File "chess.py", line 1, in <module>
    import chess
  File "/home/XusernameX/Documents/code/git/chess/chess.py", line 2, in <module>
    import chess.svg
ModuleNotFoundError: No module named 'chess.svg'; 'chess' is not a package

So I then dug into the PYTHONPATH and confirmed that the module location above is part of it.

And that is where I am. What am I missing as to why the module is not accessible via this Python file?

Trick Jarrett
  • 3,549
  • 3
  • 20
  • 17

1 Answers1

0

Abdul responded with the correct answer. My core problem was that the filename was the same as the module I wanted to load. I renamed it from chess.py to a new filename and that solved it.

Trick Jarrett
  • 3,549
  • 3
  • 20
  • 17