### Install libxcb-cursor0 on Debian/Ubuntu Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/changes/changes/2.1.60-66.mdx This command installs the necessary library for Anki to start on Linux Qt6 builds if ANKI_WAYLAND is not set. ```bash sudo apt install libxcb-cursor0 ``` -------------------------------- ### Run Anki from Python Source: https://github.com/ankitects/anki/blob/main/docs-site/faqs/running-from-python.mdx Execute Anki directly from the command line after setting up the virtual environment and installing dependencies. Repeat steps 2 and 5 to start Anki in the future. ```bash \anki-venv\scripts\anki ``` -------------------------------- ### Manual Anki Installation Steps Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/platform/linux/installing.mdx Steps to manually install Anki by extracting the downloaded archive and running the install script. Ensure zstd is installed first. ```shell tar xaf Downloads/anki-2XXX-linux-x86_64.tar.zst cd anki-linux sudo ./install.sh ``` -------------------------------- ### Install and Run Standalone Sync Server with Pip Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/sync-server.mdx Sets up a virtual environment and installs the Anki sync server package from PyPI. Ensure Python 3.9+ is installed. ```bash python3 -m venv ~/syncserver ~/syncserver/bin/pip install anki SYNC_USER1=user:pass ~/syncserver/bin/python -m anki.syncserver ``` -------------------------------- ### Install Anki Module Source: https://github.com/ankitects/anki/blob/main/docs-site/addons/command-line-use.mdx Install the Anki Python module using pip. This is the recommended way to get started. ```shell pip install anki ``` -------------------------------- ### Install Anki Beta on Windows Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/intro.mdx Use these commands to create a virtual environment, install Anki beta with Qt6 support, and run it on Windows. ```batch c:\> python -m venv \pyenv c:\> pyenv\scripts\pip install --upgrade pip c:\> pyenv\scripts\pip install --upgrade --pre aqt[qt6] c:\> pyenv\scripts\anki ``` -------------------------------- ### Install Anki Beta on Linux (ARM) Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/intro.mdx Install Anki beta on Linux ARM systems after ensuring PyQt5 packages are installed. This uses system site packages for PyQt. ```bash $ python3 -m venv --system-site-packages pyenv $ pyenv/bin/pip install --upgrade pip $ pyenv/bin/pip install --upgrade --pre aqt $ pyenv/bin/anki ``` -------------------------------- ### Install Sync Server Components from Source Checkout Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/sync-server.mdx Installs necessary components for the sync server when building from a cloned Anki GitHub repository. ```bash ./ninja extract:protoc ftl_repo cargo install --path rslib/sync ``` -------------------------------- ### Install Anki Beta on Mac/Linux (x86_64) Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/intro.mdx Use these commands to create a virtual environment, install Anki beta with Qt6 support, and run it on Mac (Intel/Apple) and Linux (x86_64). ```bash $ python3 -m venv pyenv $ pyenv/bin/pip install --upgrade pip $ pyenv/bin/pip install --upgrade --pre 'aqt[qt6]' $ pyenv/bin/anki ``` -------------------------------- ### Anki Launcher Portable Installation Batch Script Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/files.mdx This batch script is for installing and running Anki using the Anki launcher from a portable location on a flash drive. It sets environment variables for the launcher and user data directory before starting the launcher. Ensure the paths match your installation. ```bat @echo off echo Starting Anki... set USB_ROOT=%~dp0 set ANKI_LAUNCHER_VENV_ROOT=%USB_ROOT%\AnkiProgramFiles set ANKI_LAUNCHER=%USB_ROOT%\Launcher\anki set ANKI_BASE=%USB_ROOT%\AnkiData start /b %ANKI_LAUNCHER% ``` -------------------------------- ### Install Anki with Homebrew Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/platform/mac/installing.mdx Use this command to install Anki via Homebrew. Ensure Homebrew is installed on your system. ```bash brew install --cask anki ``` -------------------------------- ### Install PyQt5 for Fedora Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/intro.mdx On Fedora, install the required PyQt5 webengine package before installing Anki beta via pip. ```bash $ sudo dnf install python3-qt5-webengine ``` -------------------------------- ### Install Basic Linux Tools Source: https://github.com/ankitects/anki/blob/main/docs/linux.md Installs essential command-line utilities required for building and development on Debian/Ubuntu-based systems. ```bash $ sudo apt install bash grep findutils curl gcc gcc-12 g++ make git rsync ``` -------------------------------- ### Install Anki and Dependencies Source: https://github.com/ankitects/anki/blob/main/docs-site/faqs/running-from-python.mdx Install Anki, orjson, and pyqt6-webengine within the created virtual environment using pip. This step may take a while. ```bash \anki-venv\scripts\pip install aqt orjson pyqt6-webengine ``` -------------------------------- ### Install Dependencies for Debian/Ubuntu Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/platform/linux/installing.mdx Before installing Anki on Debian or Ubuntu, run this command to install necessary XCB libraries and NSS. ```shell sudo apt install libxcb-xinerama0 libxcb-cursor0 libnss3 libxcb-icccm4 libxcb-keysyms1 ``` -------------------------------- ### Install PyQt5 for Debian 12 Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/intro.mdx On Debian 12, install the necessary PyQt5 packages before installing Anki beta via pip. ```bash $ sudo apt install python3-pyqt6.qt{quick,webengine,multimedia} python3-venv ``` -------------------------------- ### Install Alternative Qt Version Source: https://github.com/ankitects/anki/blob/main/docs-site/faqs/running-from-python.mdx If Anki still experiences problems, try installing PyQt5 and PyQtWebEngine version 5.15.0. This may resolve compatibility issues. ```bash \anki-venv\scripts\pip install pyqt5==5.15 pyqtwebengine==5.15.0 ``` -------------------------------- ### Build Anki Installer Source: https://github.com/ankitects/anki/blob/main/docs/development.md This script builds the Anki installer. The output file location depends on your operating system. ```bash tools/build-installer ``` -------------------------------- ### Install Anki Dependencies and Type Checker Source: https://github.com/ankitects/anki/blob/main/docs-site/addons/editor-setup.mdx Installs or upgrades pip, then installs mypy and the aqt library with Qt6 support. Ensure you are using a 64-bit Python version compatible with the Anki version you are targeting. ```python import subprocess subprocess.check_call(["pip3", "install", "--upgrade", "pip"]) subprocess.check_call(["pip3", "install", "mypy", "aqt[qt6]"]) ``` -------------------------------- ### Install Basic Development Tools on Debian/Ubuntu Source: https://github.com/ankitects/anki/blob/main/docs-site/developers/linux.mdx Installs essential command-line utilities and compilers required for building Anki. Ensure these tools are present before proceeding with the build process. ```bash $ sudo apt install bash grep findutils gcc gcc-12 g++ make git rsync ``` -------------------------------- ### Install PyQt5 for Anki on Fedora 34 Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/anki2.1.50.mdx Installs the PyQt5 webengine package and creates a symbolic link for the Anki build to use the system's PyQt5 version on Fedora 34. ```bash # eg Fedora 34: sudo dnf install python3-qt5-webengine ln -sf /usr/lib64/python3.9/site-packages/PyQt5 lib/ ``` -------------------------------- ### Install Pre-commit Hook Source: https://github.com/ankitects/anki/blob/main/docs/contributing.md Installs the pre-commit hook for the pre-push event using uv. Ensure dev dependencies are installed first. ```bash uv run pre-commit install --hook-type pre-push ``` -------------------------------- ### Install Git and Rsync with pacman Source: https://github.com/ankitects/anki/blob/main/docs/windows.md Install Git and rsync using the pacman package manager within the MSYS2 UCRT64 terminal. Ensure MSYS2 is installed and the terminal is open. ```bash pacman -S git rsync ``` -------------------------------- ### Install Visual Studio Build Tools via winget Source: https://github.com/ankitects/anki/blob/main/docs/windows.md Install Visual Studio Build Tools using the winget package manager. This is a prerequisite for a minimal Rust installation. ```default winget install Microsoft.VisualStudio.BuildTools ``` -------------------------------- ### Start Anki Server for Reuse Source: https://github.com/ankitects/anki/blob/main/docs/e2e-testing.md Start Anki in a separate terminal to allow for reuse across multiple test runs. This speeds up development iteration. ```shell ./run ``` -------------------------------- ### Install libxcrypt-compat on Fedora Source: https://github.com/ankitects/anki/blob/main/docs/linux.md Installs the necessary compatibility package on Fedora if encountering errors related to libcrypt.so.1. ```bash sudo apt install libxcrypt-compat ``` -------------------------------- ### Install aqt with PyQt6 support Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/anki2.1.50.mdx When installing the aqt package, you can specify the major PyQt version you wish to use, such as PyQt6. ```bash pip install 'aqt[qt6]' ``` -------------------------------- ### Starting Anki with Console on Windows Source: https://github.com/ankitects/anki/blob/main/docs-site/addons/console-output.mdx To see console output on Windows, start Anki using the anki-console.bat script. This will open a separate console window. ```batch C:\Users\user\AppData\Local\Programs\Anki\anki-console.bat ``` -------------------------------- ### Install Pre-commit Hook (Python) Source: https://github.com/ankitects/anki/blob/main/docs/contributing.md Installs the pre-commit hook for the pre-push event using the python3 module. This is an alternative to using uv. ```bash python3 -m pre_commit install --hook-type pre-push ``` -------------------------------- ### Install zstd for Linux Builds Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/changes/changes/2.1.50-59.mdx On Linux, Anki builds require the 'zstd' utility for decompression. Install it using your package manager. ```shell sudo apt install zstd tar xaf anki-2.1.50-linux-qt6.tar.zstd ``` -------------------------------- ### Install PyQt5 for Anki on Debian 11 Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/anki2.1.50.mdx Installs necessary PyQt5 packages and creates a symbolic link for the Anki build to use the system's PyQt5 version on Debian 11. ```bash # eg Debian 11: sudo apt install python3-pyqt5.{qtwebengine,qtmultimedia} ln -sf /usr/lib/python3/dist-packages/PyQt5 lib/ ``` -------------------------------- ### Multi-line Translation Example (Problematic) Source: https://github.com/ankitects/anki/blob/main/docs-site/translators/anki/core.mdx Illustrates a problematic multi-line translation where lines starting with '[' or '.' cause issues. ```ini some-translation = [This is a translation that occurs over ...two or three lines.] ``` -------------------------------- ### Setting up and using Monkeytype for Type Hinting Source: https://github.com/ankitects/anki/blob/main/docs-site/addons/mypy.mdx This sequence of shell commands demonstrates how to set up a Python virtual environment, install necessary packages (aqt, monkeytype), and run monkeytype to gather runtime type information for an add-on. ```shell % /usr/local/bin/python3.8 -m venv pyenv % cd pyenv && . bin/activate (pyenv) % pip install aqt monkeytype (pyenv) % monkeytype run bin/anki ``` -------------------------------- ### Run Sync Server on Windows Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/sync-server.mdx Starts the sync server using the bundled Anki executable on Windows. Ensure the SYNC_USER1 environment variable is set. ```bash set SYNC_USER1=user:pass "Program Files\anki\anki-console" --syncserver ``` -------------------------------- ### Wildcard Search in Fields Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/older.mdx Wildcards can now be used when limiting searches to a specific field. This example searches for 'something' in fields starting with 'field'. ```text field*:something ``` -------------------------------- ### Search for 'dog' with trailing wildcard Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/changes/changes/2.1.20-29.mdx Use `w:something*` to match words starting with a prefix. This example matches 'dog' and 'doggy', but not 'underdog'. ```text w:dog* ``` -------------------------------- ### Search Tag Prefix Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/searching.mdx Find notes with tags that start with a specific prefix. For example, `tag:ani*` finds tags like 'animal' or 'animation'. ```text tag:ani* ``` -------------------------------- ### Match Literal Hyphen Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/searching.mdx To search for a hyphen that would otherwise invert a search (e.g., starting with '-'), use a backslash or quotes. Examples: '\-free' or '"-free"'. ```text \-free ``` ```text "-free" ``` -------------------------------- ### Start Anki with Custom Base Folder (macOS Terminal) Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/files.mdx On macOS, you can launch Anki from the terminal with a custom base folder using the 'open' command and passing the -b argument. This is useful for testing or portable setups. ```text open /Applications/Anki.app --args -b ~/myankifolder ``` -------------------------------- ### Anki Portable Installation Batch Script (No Command Prompt) Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/files.mdx An alternative batch script for running Anki as a portable application that prevents the command prompt window from remaining open after Anki starts. Adjust drive letters and paths as needed. ```bat start /b E:\anki\anki.exe -b E:\ankidata ``` -------------------------------- ### Run Sync Server on Linux Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/sync-server.mdx Starts the sync server using the Anki executable on Linux. Ensure the SYNC_USER1 environment variable is set. ```bash SYNC_USER1=user:pass anki --syncserver ``` -------------------------------- ### Anki Portable Installation Batch Script Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/files.mdx This batch script is used to run Anki as a portable application from a flash drive. It specifies the Anki executable path and the directory for user data. Ensure the drive letter and paths are adjusted to your specific setup. ```bat E:\anki\anki.exe -b E:\ankidata ``` -------------------------------- ### Generate Documentation Source: https://github.com/ankitects/anki/blob/main/docs/development.md Run this command to build and view the Anki documentation site. Ensure you are in the project root. ```bash just docs ``` -------------------------------- ### List Available Release Recipes Source: https://github.com/ankitects/anki/blob/main/docs-site/developers/releasing.mdx Run this command to see all available 'just' recipes for the release module and their arguments. ```bash just --list --list-submodules ``` -------------------------------- ### Initialize and Use Anki Collection in Python Source: https://github.com/ankitects/anki/blob/main/docs-site/addons/command-line-use.mdx Demonstrates how to import the Collection class, initialize a collection from a file path, and print the due deck tree. Ensure the collection file path is correct. ```python from anki.collection import Collection col = Collection("/path/to/collection.anki2") print(col.sched.deck_due_tree()) ``` -------------------------------- ### Set up PyCharm/IntelliJ Python Environment Source: https://github.com/ankitects/anki/blob/main/docs/editing.md Copy the .idea.dist directory to .idea in the project root to automatically configure source paths for PyCharm/IntelliJ, enabling recognition of 'anki' and 'aqt' imports. ```default mkdir .idea && cd .idea ln -sf ../.idea.dist/* . ``` -------------------------------- ### Run Anki Sync Server with Docker Source: https://github.com/ankitects/anki/blob/main/docs/syncserver/README.md Use this command to start a single-user Anki sync server. Ensure the volume 'anki-sync-server-data' is created and accessible. ```bash docker run -d \ -e "SYNC_USER1=admin:admin" \ -p 8080:8080 \ --mount type=volume,src=anki-sync-server-data,dst=/anki_data \ --name anki-sync-server \ anki-sync-server ``` -------------------------------- ### Set up VS Code Workspace Settings Source: https://github.com/ankitects/anki/blob/main/docs/editing.md Run these commands in the project root to create and populate the .vscode directory with recommended workspace settings for Anki development. ```default mkdir .vscode && cd .vscode ln -sf ../.vscode.dist/* . ``` -------------------------------- ### Install Dependencies for Arch/Manjaro Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/platform/linux/installing.mdx Before installing Anki on Arch Linux or derivatives like Manjaro, run this command to install required libraries. ```shell sudo pacman -S libxinerama xcb-util-cursor nss ``` -------------------------------- ### Install zstd and Extract Anki Linux Build Source: https://github.com/ankitects/anki/blob/main/docs-site/releases/betas/anki2.1.50.mdx On Linux, you need to install the zstd package to decompress the Anki build archive. Use tar to extract the archive after installation. ```shell sudo apt install zstd tar axf anki-2.1.50-linux-qt6.tar.zstd ``` -------------------------------- ### Build Anki Sync Server Image for Default Platform Source: https://github.com/ankitects/anki/blob/main/docs-site/developers/syncserver.mdx Builds the Anki Sync Server image for the default platform of your system. Use this command if you are unsure of your system's architecture or do not require multi-platform support. Replace `` and `` with your specific values. ```bash # Execute this command from this directory docker buildx build -f --no-cache --build-arg ANKI_VERSION= -t anki-sync-server . ``` -------------------------------- ### Generate Rust API Documentation Source: https://github.com/ankitects/anki/blob/main/docs/development.md Execute this command to specifically build the documentation for the Rust API components of Anki. ```bash just docs-rust ``` -------------------------------- ### Starting Anki with Console on Linux Source: https://github.com/ankitects/anki/blob/main/docs-site/addons/console-output.mdx On Linux, open a terminal or xterm and run Anki using the 'anki' command to display console output. ```bash anki ``` -------------------------------- ### Example Multiple Choice Question Source: https://github.com/ankitects/anki/blob/main/docs-site/faqs/multiple-choice-questions.mdx An example of a multiple choice question as it might appear in a test. ```text Q: What animal has a really long neck? A: 1. A monkey. 2. A giraffe. 3. A donkey. 4. A snail. ``` -------------------------------- ### Run Sync Server on MacOS Source: https://github.com/ankitects/anki/blob/main/docs-site/manual/sync-server.mdx Starts the sync server using the bundled Anki application on MacOS. Ensure the SYNC_USER1 environment variable is set. ```bash SYNC_USER1=user:pass /Applications/Anki.app/Contents/MacOS/anki --syncserver ``` -------------------------------- ### Setup Sphinx Documentation Links for Offline Build Source: https://github.com/ankitects/anki/blob/main/docs/linux.md Creates symbolic links for Sphinx tools within the 'out/pyenv/bin' directory, enabling offline generation of Sphinx documentation. ```bash ln -s /path/to/sphinx-apidoc out/pyenv/bin/sphinx-apidoc ln -s /path/to/sphinx-build out/pyenv/bin/sphinx-build ``` -------------------------------- ### Setup VS Code Workspace Settings Source: https://github.com/ankitects/anki/blob/main/docs-site/developers/editing.mdx Create and populate the .vscode directory with default workspace settings optimized for Anki development. This involves creating the directory and linking configuration files from the .vscode.dist directory. ```bash mkdir .vscode && cd .vscode ln -sf ../.vscode.dist/* . ```