Play chess in Python programming language? I am searching for a program/library in Python which will let two users or a user and an AI play chess with each other.

PS: I have found python-chess. Can this be used for the above along with a chess engine?
Yes. You can use the package to play against yourself and an engine. While I don't think there is one function that can do everything for you, but I can give you hints:

To setup up a game against an AI:


Read UCI documentation (you can find on Google)
Read the UCI functions for python-chess here
Spawn an engine thread by engine = chess.uci.popen_engine("/usr/games/stockfish")
Start a new game by engine.uci()
Send a move by engine.position
Start analysis by engine.go
Get engine results by command.result()


You will need to read the documentation carefully.

To setup a game against yourself (copied from the package documentation)

&gt;&gt;&gt; import chess

&gt;&gt;&gt; board = chess.Board()

&gt;&gt;&gt; board.push_san("e4")
Move.from_uci('e2e4')
&gt;&gt;&gt; board.push_san("e5")
Move.from_uci('e7e5')
&gt;&gt;&gt; board.push_san("Qh5")
Move.from_uci('d1h5')
&gt;&gt;&gt; board.push_san("Nc6")
Move.from_uci('b8c6')
&gt;&gt;&gt; board.push_san("Bc4")
Move.from_uci('f1c4')
&gt;&gt;&gt; board.push_san("Nf6")
Move.from_uci('g8f6')
&gt;&gt;&gt; board.push_san("Qxf7")
Move.from_uci('h5f7')