Registry / auth-security / pyscard

pyscard

JSON →
library2.3.1pypypiunverified

pyscard is a Python library for smart card communication using PC/SC API. It provides high-level wrappers for reading/writing to smart cards, monitoring card insertion/removal, and sending APDUs. Version 2.3.1 (October 2025) supports Python >=3.9 and SWIG 4.4. Active development with monthly releases.

pip install pyscard
INSTALL
IMPORT
SIG · PYSCARD
P
pyscard
auth-securitypythonv2.3.1
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CardRequest
from smartcard.CardRequest import CardRequest
from smartcard import CardRequest
CardRequest is in a submodule, not directly in smartcard
CardConnection
from smartcard.CardConnection import CardConnection
import smartcard.CardConnection
CardConnection is a class, not a module
SCardGetErrorMessage
from smartcard.scard import SCardGetErrorMessage
from smartcard import SCardGetErrorMessage
SCard* functions are in scard submodule

Wait up to 5 seconds for a smart card, connect, retrieve and print the ATR.

import smartcard.util from smartcard.CardRequest import CardRequest from smartcard.CardConnection import CardConnection def get_atr(): request = CardRequest(timeout=5) card_service = request.waitforcard() card_service.connection.connect() atr = card_service.connection.getATR() print('ATR:', smartcard.util.toHexString(atr)) card_service.connection.disconnect() if __name__ == '__main__': get_atr()
Debug
Known issues
gotchapyscard requires PC/SC service running. On Linux, ensure pcscd is installed and started (e.g., sudo systemctl start pcscd).
fix
Install and start pcscd: sudo apt install pcscd && sudo systemctl enable --now pcscd
affects: all
deprecatedDirect import of smartcard.scard functions like SCardEstablishContext is discouraged; use higher-level classes CardRequest and CardConnection.
fix
Use from smartcard.scard import SCardEstablishContext only if necessary; prefer CardRequest
affects: >=2.0.0
breakingIn 2.3.0, SCardListReaders() and SCardListReaderGroups() were fixed to use SCARD_AUTOALLOCATE. Code relying on manual memory management may break.
fix
Update code to not manually allocate buffers; let pyscard handle memory.
affects: 2.3.0+
breakingIn 2.3.0, connecting after releasing a connection raises an exception. Code that reuses a released connection will break.
fix
Create a new CardConnection or CardRequest after release.
affects: 2.3.0+
Upgrade
Version history
2.3.1latest on PyPI · released Oct 29, 2025
Audit
Dependencies
pyscardrequiredRequires PC/SC service (pcscd on Linux, winscard on Windows, SmartCardServices on macOS)
Agent activity
42 hits · last 30 days
node
36
OpenAI (training)
1
Resources
pyscard — pip install pyscard · libregistry