See AnkiBrain on AnkiWeb for more information.
Please notice that this addon doesn't work when Anki is installed as a Flatpak. To resolve this, simply install Anki from the official website using the .deb package.
Open terminal in the AnkiBrain addon root folder (you'll see a requirements.txt
file)
Install C++ build tools for your OS
xcode-select --install
sudo apt install -y git build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Setup Python 3.9.13 virtual environment in the root addon directory
Install pyenv
for your operating system
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
MacOS
# Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew install pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
exec "$SHELL"
Linux
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile
. ~/.bashrc
. ~/.profile
pyenv install 3.9.13
pyenv local 3.9.13
python -m venv venv
Activate Python virtual environment
.\venv\Scripts\active
./venv/bin/activate
Install python dependencies
pip install -r requirements.txt
Addon should be OK to run now