{"id":4420,"library":"anki-release","title":"Anki Release (Dependency Locker)","description":"Anki-release is a Python meta-package designed to lock the dependencies required for the Anki desktop application's Python components, ensuring a consistent and compatible environment for developers building on the Anki backend. It does not provide direct user-facing API but facilitates the installation of the core `anki` and `aqt` libraries along with their many transitive dependencies. It follows Anki's rapid release cadence, with the current version being 25.9.2.","status":"active","version":"25.9.2","language":"en","source_language":"en","source_url":"https://github.com/ankitects/anki","tags":["anki","flashcards","spaced-repetition","education","backend","utility"],"install":[{"cmd":"pip install anki-release","lang":"bash","label":"Install `anki-release`"}],"dependencies":[{"reason":"Core Anki backend functionality.","package":"anki","optional":false},{"reason":"Anki's Qt-based GUI components (desktop frontend).","package":"aqt","optional":false},{"reason":"GUI framework dependency for aqt.","package":"pyqt6","optional":false},{"reason":"Dependency for structured attributes.","package":"attrs","optional":false},{"reason":"HTTP library for network operations.","package":"requests","optional":false}],"imports":[{"note":"anki-release itself is not imported for functionality; it enables importing from the 'anki' package for backend operations.","symbol":"Collection","correct":"from anki.collection import Collection"},{"note":"For accessing the main Anki window and its functionalities when extending the GUI (e.g., add-ons).","symbol":"mw","correct":"from aqt import mw"}],"quickstart":{"code":"import os\nfrom anki.collection import Collection\nfrom anki.stdrepl import repl\n\n# NOTE: For anki-release, the primary use case is to ensure backend dependencies.\n# The actual Anki backend interaction is via the 'anki' package.\n\n# Create a temporary Anki collection for demonstration\n# In a real scenario, you'd likely open an existing collection.\nCOLLECTION_PATH = os.environ.get('ANKI_TEST_COLLECTION_PATH', 'temp_collection.anki2')\n\n# Ensure the directory exists if not in the current working directory\ncollection_dir = os.path.dirname(COLLECTION_PATH)\nif collection_dir and not os.path.exists(collection_dir):\n    os.makedirs(collection_dir)\n\n# Open or create an Anki collection\ncol = Collection(COLLECTION_PATH)\nprint(f\"Opened Anki collection at: {col.path}\")\n\n# Example: Get number of notes (0 for a new collection)\nprint(f\"Number of notes: {col.note_count()}\")\n\n# Clean up the temporary collection if created new\n# In a real application, you'd manage persistence carefully.\n# col.close()\n# if not os.environ.get('ANKI_TEST_COLLECTION_PATH'):\n#     os.remove(COLLECTION_PATH)\n\n# Anki's internal Python environment might use a custom REPL for debugging\n# For general scripting, standard Python interactions apply.\n# You might interact with objects like col.models, col.decks, etc.\n","lang":"python","description":"This quickstart demonstrates installing `anki-release` and then provides a minimal example of how to interact with the Anki backend (`anki` package) by opening an Anki collection. This package primarily sets up the environment, and direct programmatic interaction is typically done through the `anki` and `aqt` libraries it depends on."},"warnings":[{"fix":"Consult the Anki license (AGPL-3.0-or-later) and consider its implications for your project's licensing. If creating a closed-source application, contact Anki's developers for an exception or consider alternatives.","message":"Anki (and thus anki-release) is licensed under AGPL-3.0-or-later. Using Anki's backend in a closed-source application generally requires a specific exception from the developers or adherence to the AGPL's terms, which often means open-sourcing your derived work.","severity":"breaking","affected_versions":"All versions"},{"fix":"For the full desktop application, download it from https://apps.ankiweb.net. Use `anki-release` for programmatic access or add-on development within a Python environment.","message":"The `anki-release` package provides the *backend* and GUI components for the desktop application, not the Anki desktop application installer itself. Running `pip install anki-release` will set up the Python environment but won't install the executable application. Users typically interact with the Anki desktop app downloaded from AnkiWeb.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the latest Anki developer documentation for backend interactions. Stay updated with Anki's release notes for changes impacting the `anki` Python package API. Test thoroughly after major Anki desktop updates.","message":"Anki's internal architecture, especially how it handles the collection backend, has undergone significant changes (e.g., transition to Rust-based `rslib` wrapped by Python). These changes can affect direct interactions with the `anki` package, potentially breaking code relying on older internal structures.","severity":"breaking","affected_versions":"Versions 2.1.50+ (or 25.x.x+ in new numbering)"},{"fix":"Pin `anki-release` to a specific version in your `requirements.txt` to ensure stability. Regularly check Anki's official release notes on GitHub (ankitects/anki) for potential breaking changes relevant to the backend.","message":"The version numbers for `anki-release` (e.g., 25.9.2) are directly tied to the Anki desktop application's release versions, not independent Python package versions. This means changes are frequent and often non-backward compatible without clear 'major' version breaks in the traditional Python sense.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When importing shared decks programmatically, ensure you understand the options for stripping scheduling information if it's not desired. Anki 23.10+ (and thus 25.x.x) allows removing learning progress during import.","message":"When importing or updating packaged decks (.apkg files) using the Anki backend, be aware that scheduling information might be included unintentionally. This can lead to unexpected review intervals or card states if not handled correctly.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}