{"id":24733,"library":"treys","title":"treys","description":"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.","status":"active","version":"0.1.8","language":"python","source_language":"en","source_url":"https://github.com/ihendley/treys","tags":["poker","hand-evaluation","card-games","games"],"install":[{"cmd":"pip install treys","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Card is exported at package level","wrong":"from treys.card import Card","symbol":"Card","correct":"from treys import Card"},{"note":"Deck is exported at package level","wrong":"from treys.deck import Deck","symbol":"Deck","correct":"from treys import Deck"},{"note":"Evaluator is exported at package level","wrong":"from treys.evaluator import Evaluator","symbol":"Evaluator","correct":"from treys import Evaluator"}],"quickstart":{"code":"from treys import Card, Deck, Evaluator\n\ndeck = Deck()\nboard = deck.draw(5)\nhand = deck.draw(2)\n\nevaluator = Evaluator()\nrank = evaluator.evaluate(board, hand)\nprint(\"Hand rank:\", evaluator.class_to_string(evaluator.get_rank_class(rank)))\nprint(\"Hand description:\", evaluator.get_hand_description(board, hand))","lang":"python","description":"Basic usage: create a deck, draw a community board and a hand, then evaluate the hand rank."},"warnings":[{"fix":"Use Card.new or Card.from_str to create cards from string, not the Card constructor directly.","message":"Card objects printed as strings show a representation like 'Ah' (Ace of hearts), but for input use Card.new('Ah') or Card.from_str('Ah').","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'from treys import Card, Deck, Evaluator' instead of deep imports.","message":"In 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.","severity":"breaking","affected_versions":">=0.1.7"},{"fix":"No action needed; just be aware of the two-step process to get a rank string.","message":"The 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.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from treys import Card' instead of 'import treys'.","cause":"Old import pattern 'import treys' and then 'treys.Card' does not work because Card is not automatically imported. The library uses explicit submodule imports.","error":"AttributeError: module 'treys' has no attribute 'Card'"},{"fix":"Use 'Th' for ten of hearts. For full card string, e.g., 'Ah' for Ace of hearts.","cause":"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'.","error":"ValueError: The card '10h' could not be interpreted"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}