Anki Forums

Support for python 3.9 is urgently required

Hello, my distro has upgraded python to 3.9 so I can not use anki anymore.
Please, fix the code.

With best regards,
Dmitry

If the packaged version of Anki doesn’t work on your distro, you’ll need to compile it yourself.

My distro is Slackware-current.

And I can not compile it myself. At the moment I have been trying to compile v.2.1.16
And after

pip3 install -r requirements.txt
pip3 install pyqt5
pip3 install PyQtWebEngine
pip3 install PyQtWebEngineWidgets

I get the message

ERROR: Could not find a version that satisfies the requirement PyQtWebEngineWidgets (from versions: none)
ERROR: No matching distribution found for PyQtWebEngineWidgets

At the moment I see

If you're running from git, did you run build_ui.sh?

Traceback (most recent call last):
  File "/home/dima/devel/python/anki/runanki", line 3, in <module>
    import aqt
  File "/home/dima/devel/python/anki/aqt/__init__.py", line 32, in <module>
    import aqt.forms
ModuleNotFoundError: No module named 'aqt.forms'

While there was python 3.7 all worked this way

Today I’ve tried to run anki-2.1.35

$ pip install aqt anki ankirspy pyqt5 pyqtwebengine
Collecting aqt
  Downloading aqt-2.1.35-py3-none-any.whl (9.3 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 9.3 MB 1.6 MB/s 
Collecting anki
  Downloading anki-2.1.35-py3-none-any.whl (161 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 161 kB 1.5 MB/s 
ERROR: Could not find a version that satisfies the requirement ankirspy (from versions: none)
ERROR: No matching distribution found for ankirspy

The wheels on PyPI require an x86_64 Linux, but you appear to be using something else.

Doch, I use Slackware-current64, probably, the detection failed.

$ uname -m
x86_64

Ah, it would be because ankirspy only targets Python 3.8. If you’re on a 64 bit machine it shouldn’t be too hard to compile it yourself - if you have trouble with 2.1.35 you may like to try the latest beta version instead.

The topic includes β€œpython 3.9”

Yes, you’re right. Did you try the beta wheels on https://betas.ankiweb.net/#/? They theoretically will work on Python 3.9.

Will try at the evening… Thanks.

Which commit will you recommend?

I was suggesting the whl files on the download site: https://apps.ankiweb.net/downloads/beta/. It says cp38, but that should be a minimum rather than a specific requirement.

What is β€œcp38”?

I think cp refers to CPython, the standard implementation of Python, which is most likely what you have. 38 is for 3.8 obviously.

I can confirm that Anki compiles successfully with Python 3.9.

1 Like

Thanks, will try

I have run ./run in stable brunch (84dcaa86 (HEAD -> stable, tag: 2.1.35, origin/stable) backport qt5.9 opacity fix).

It returns

$ ./run 
make: Entering directory '/home/dima/devel/python/anki'
make[1]: Entering directory '/home/dima/devel/python/anki/rslib'
make[1]: Nothing to be done for 'develop'.
make[1]: Leaving directory '/home/dima/devel/python/anki/rslib'
make[1]: Entering directory '/home/dima/devel/python/anki/rspy'
make[1]: Nothing to be done for 'develop'.
make[1]: Leaving directory '/home/dima/devel/python/anki/rspy'
make[1]: Entering directory '/home/dima/devel/python/anki/pylib'
protoc --proto_path=../proto --python_out=anki --mypy_out=anki ../proto/backend.proto ../proto/fluent.proto
Writing mypy to backend_pb2.pyi
Writing mypy to fluent_pb2.pyi
perl -i'' -pe 's/from fluent_pb2/from anki.fluent_pb2/' anki/backend_pb2.pyi
perl -i'' -pe 's/import fluent_pb2/import anki.fluent_pb2/' anki/backend_pb2.py
python tools/genbackend.py
Traceback (most recent call last):
  File "/home/dima/devel/python/anki/pylib/tools/genbackend.py", line 6, in <module>
    from anki import backend_pb2 as pb
  File "/home/dima/devel/python/anki/pylib/anki/__init__.py", line 7, in <module>
    from anki.collection import Collection
  File "/home/dima/devel/python/anki/pylib/anki/collection.py", line 15, in <module>
    import anki.find
  File "/home/dima/devel/python/anki/pylib/anki/find.py", line 8, in <module>
    from anki.hooks import *
  File "/home/dima/devel/python/anki/pylib/anki/hooks.py", line 20, in <module>
    from anki.cards import Card
  File "/home/dima/devel/python/anki/pylib/anki/cards.py", line 13, in <module>
    from anki.models import NoteType, Template
  File "/home/dima/devel/python/anki/pylib/anki/models.py", line 15, in <module>
    from anki.rsbackend import NotFoundError, StockNoteType, from_json_bytes, to_json_bytes
  File "/home/dima/devel/python/anki/pylib/anki/rsbackend.py", line 22, in <module>
    import ankirspy  # pytype: disable=import-error
ModuleNotFoundError: No module named 'ankirspy'
make[1]: *** [Makefile:48: .build/py-proto] Error 1
make[1]: Leaving directory '/home/dima/devel/python/anki/pylib'
make: *** [Makefile:94: develop] Error 2
make: Leaving directory '/home/dima/devel/python/anki'

While

$ pip install ankirspy
ERROR: Could not find a version that satisfies the requirement ankirspy (from versions: none)
ERROR: No matching distribution found for ankirspy

Are there any suggestions?

I suggest you try what I suggested above, or show what problems you ran into when trying it.

$ cd anki-2.1.36-linux-amd64/
$ ./bin/anki
Traceback (most recent call last):
  File "runanki", line 3, in <module>
  File "/home/dae/Local/py514/lib/python3.8/site-packages/PyInstaller-4.0.dev0+g2886519-py3.8.egg/PyInstaller/loader/pyimod03_importers.py", line 625, in exec_module
  File "aqt/__init__.py", line 22, in <module>
  File "/home/dae/Local/py514/lib/python3.8/site-packages/PyInstaller-4.0.dev0+g2886519-py3.8.egg/PyInstaller/loader/pyimod03_importers.py", line 625, in exec_module
  File "aqt/qt.py", line 18, in <module>
ImportError: libsystemd.so.0: cannot open shared object file: No such file or directory
[15356] Failed to execute script runanki

That’s the packaged version of Anki, not the whl files I was talking about, which are in the wheels subfolder. You won’t be able to use the packaged version because you’re using a distro that doesn’t have systemd.