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:
engine = chess.uci.popen_engine("/usr/games/stockfish")
You will need to read the documentation carefully.
To setup a game against yourself (copied from the package documentation)
>>> import chess >>> board = chess.Board() >>> board.push_san("e4") Move.from_uci('e2e4') >>> board.push_san("e5") Move.from_uci('e7e5') >>> board.push_san("Qh5") Move.from_uci('d1h5') >>> board.push_san("Nc6") Move.from_uci('b8c6') >>> board.push_san("Bc4") Move.from_uci('f1c4') >>> board.push_san("Nf6") Move.from_uci('g8f6') >>> board.push_san("Qxf7") Move.from_uci('h5f7')
You mentioned an AI. It might not be very strong, but sunfish is an example of a Python-based chess program, should you decide to go down that route.
Do also bear in mind that XBoard protocol is a valid option, using Polyglot by Fabien Letouzey to convert from UCI to XBoard. It is much harder to convert from XBoard to UCI, through something like WB2UCI by Odd Gunnar Malin, as XBoard is much more lax about things like thinking output.
I would recommend creating an account on the Computer Chess Club if you are going to create a GUI.
Cutechess cli ( https://chessprogramming.wikispaces.com/Cutechess-cli ) by Ilari Pihlajisto, is often used to run automated engine-engine matches. There is also work on a python port. ( http://www.talkchess.com/forum/viewtopic.php?t=60504 ) Github: https://github.com/lucasart/zinc