Installation¶
Requirements¶
Python 3.10+
CMake 3.15+
C++14 compatible compiler (GCC, Clang, or MSVC)
Install from PyPI¶
pip install pymahjong
Verify Installation¶
from pymahjong.test import test
test()
If installation is successful, you should see output like:
Total 100 random-play games, 100 games without error, takes X.XX s
Install from Source¶
Prerequisites¶
Python 3.10+
CMake 3.15+
C++14 compiler:
Linux: GCC or Clang
macOS: Clang (Xcode Command Line Tools)
Windows: MSVC (Visual Studio Build Tools)
Clone and Install¶
git clone https://github.com/Agony5757/mahjong.git
cd mahjong
pip install .
Development Installation¶
For development, install with extra dependencies:
pip install -e ".[dev,docs]"
Optional Dependencies¶
PyTorch (for pretrained models)¶
To use pretrained opponent models in single-agent mode:
pip install torch
Download pretrained models from GitHub Releases.
Development Tools¶
pip install -e ".[dev]"
Includes: pytest, ruff
Documentation Tools¶
pip install -e ".[docs]"
Includes: sphinx, furo, myst-parser, sphinx-autodoc-typehints, sphinx-copybutton
Platform-specific Notes¶
Linux¶
# Ubuntu/Debian
sudo apt-get install cmake g++ ninja-build
# Fedora
sudo dnf install cmake gcc-c++ ninja-build
macOS¶
# Install Xcode Command Line Tools
xcode-select --install
# Install cmake (via Homebrew)
brew install cmake ninja
Windows¶
Install Visual Studio Build Tools with C++ workload
Install CMake from cmake.org
Ensure
cmakeis in your PATH
Troubleshooting¶
Build Errors¶
If you encounter build errors:
Ensure CMake 3.15+ is installed:
cmake --versionEnsure you have a C++14 compatible compiler
Try building with verbose output:
pip install . -v
Import Errors¶
If import pymahjong fails after installation:
Check if the package is installed:
pip show pymahjongTry reinstalling:
pip install --force-reinstall pymahjongCheck Python version:
python --version(requires 3.10+)