Installation
System Dependencies
pythaiidcard requires several system-level dependencies for PC/SC smartcard communication.
Linux (Debian/Ubuntu)
What these packages do:
pcscd- PC/SC Smart Card Daemon (manages smartcard readers)libpcsclite-dev- Development files for PC/SC Lite librarypython3-dev- Python development headers (required for pyscard compilation)swig- Interface compiler for Python bindings
Other Linux Distributions
Verify Installation
After installing system dependencies, verify that the PC/SC daemon is running:
If it's not running, start it:
Python Package Installation
Using pip (Recommended)
Using uv (Fast)
From Source
Dependency Check
pythaiidcard automatically checks for required system dependencies on Linux systems. If dependencies are missing, you'll see a helpful error message:
from pythaiidcard import ThaiIDCardReader
reader = ThaiIDCardReader()
# SystemDependencyError: Missing required system dependencies:
#
# ✗ PC/SC Smart Card Daemon (pcscd)
# ✗ PC/SC Lite development library (libpcsclite-dev)
#
# To install missing dependencies, run:
#
# sudo apt-get update && sudo apt-get install -y pcscd libpcsclite-dev python3-dev swig
Skipping the Check
If you've installed dependencies via other means or want to skip the check:
Hardware Setup
Hardware Compatibility
Not all smartcard readers behave the same. Some readers have hardware limitations that may affect functionality. See Hardware Compatibility for tested readers and known issues.
Recommended Hardware
The library works with any PC/SC compatible smartcard reader. The author uses and recommends:
USB-C Smart Card Reader

- Product: USB-C Smart Card Reader
- Link: Available on Shopee (affiliate link)
- Features:
- USB-C connection
- Compact and portable
- Works with Thai National ID cards
- PC/SC compatible
- Plug and play on Linux
Affiliate Disclosure
The Shopee link above is an affiliate link. The author may earn a commission from purchases made through this link at no additional cost to you.
Alternative Readers
Any PC/SC compatible smartcard reader will work, including:
- Generic USB smartcard readers
- Gemalto readers
- ACS ACR122U
- Built-in laptop smartcard readers
Known Limitations
Alcor Link AK9563: This reader has known limitations with auto-read functionality. It works perfectly in on-demand mode (default in v2.2.0+). See Hardware Compatibility for details.
Connect Your Smartcard Reader
- Plug in your PC/SC compatible smartcard reader
- Verify it's detected:
You should see output like:
PC/SC device scanner
V 1.6.2 (c) 2001-2022, Ludovic Rousseau <ludovic.rousseau@free.fr>
...
Reader 0: Generic USB Smart Card Reader
Press Ctrl+C to exit.
Permissions (Optional)
If you encounter permission issues, add your user to the scard group:
Then log out and log back in for the changes to take effect.
Verify Installation
Test that everything is working:
from pythaiidcard import ThaiIDCardReader
# List available readers
readers = ThaiIDCardReader.list_readers()
for r in readers:
print(f"Reader {r.index}: {r.name}")
print(f" Status: {'Card Present' if r.connected else 'No Card'}")
Development Installation
For development with all optional dependencies:
# Clone the repository
git clone https://github.com/ninyawee/pythaiidcard.git
cd pythaiidcard
# Install with development dependencies
uv sync --group dev
# Install system dependencies
mise run install-deps # If you have mise installed
Development Tools
The development environment includes:
- ruff - Linting and formatting
- streamlit - Web UI for debugging
- mkdocs-material - Documentation generation
Running Tests
# Run linting
uv run ruff check .
# Format code
uv run ruff format .
# Run the web UI
uv run streamlit run debug/app.py
Troubleshooting
See the Troubleshooting guide for common installation issues.
Next Steps
- Hardware Compatibility → - Check your reader compatibility
- Usage Guide → - Learn how to use the library
- API Reference → - Detailed API documentation