Registry / data / treys
library0.1.8pypypi✓ verified 88d ago

treys is a pure Python poker hand evaluation library. It provides fast evaluation of 5-, 6-, and 7-card poker hands, as well as deck and card utilities. Current version 0.1.8 is stable with low release cadence.

pip install treys
INSTALL
IMPORT
SIG · TREYS
T
treys
datapythonv0.1.8
Install
1.6s avg
Import
14ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.8 · pip install
no network on importno background threads
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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 17.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.014s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

Card
✓ from treys import Card
✗ from treys.card import Card
Card is exported at package level
Deck
✓ from treys import Deck
✗ from treys.deck import Deck
Deck is exported at package level
Evaluator
✓ from treys import Evaluator
✗ from treys.evaluator import Evaluator
Evaluator is exported at package level

Basic usage: create a deck, draw a community board and a hand, then evaluate the hand rank.

from treys import Card, Deck, Evaluator deck = Deck() board = deck.draw(5) hand = deck.draw(2) evaluator = Evaluator() rank = evaluator.evaluate(board, hand) print("Hand rank:", evaluator.class_to_string(evaluator.get_rank_class(rank))) print("Hand description:", evaluator.get_hand_description(board, hand))
Debug
Known issues
gotchaCard objects printed as strings show a representation like 'Ah' (Ace of hearts), but for input use Card.new('Ah') or Card.from_str('Ah').
fix
Use Card.new or Card.from_str to create cards from string, not the Card constructor directly.
affects: all
breakingIn version 0.1.6 and earlier, the import path was 'treys.card', 'treys.deck', 'treys.evaluator'. In 0.1.7+ the public API changed to import from 'treys' directly.
fix
Use 'from treys import Card, Deck, Evaluator' instead of deep imports.
affects: >=0.1.7
deprecatedThe method evaluator.get_rank_class() returns an integer; evaluator.class_to_string() converts it to a human-readable rank string. There is no plan to remove but usage is stable.
fix
No action needed; just be aware of the two-step process to get a rank string.
affects: all
Errors
Common errors & fixes
AttributeError: module 'treys' has no attribute 'Card'
Old import pattern 'import treys' and then 'treys.Card' does not work because Card is not automatically imported. The library uses explicit submodule imports.
fix
Use 'from treys import Card' instead of 'import treys'.
ValueError: The card '10h' could not be interpreted
Hand string '10h' is invalid; treys expects single-character ranks (2-9, T, J, Q, K, A) and suits (h, d, c, s). Ten is represented as 'Th'.
fix
Use 'Th' for ten of hearts. For full card string, e.g., 'Ah' for Ace of hearts.
Upgrade
Version history
0.1.8latest on PyPI · released Jun 21, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
37 hits · last 30 days
node
32
OpenAI (training)
1
Resources
treys — pip install treys · libregistry