Setting up PyCharm for addon development

I’m having problems following this tutorial: https://addon-docs.ankiweb.net/#/getting-started

When I try to run these commands in the Python console:

import subprocess
subprocess.check_call([“pip”, “install”, “mypy”, “anki”, “ankirspy”, “aqt”])

I get the following output:

Collecting mypy
Using cached mypy-0.780-py3-none-any.whl (1.8 MB)
Collecting anki
Using cached anki-2.1.26-py3-none-any.whl (156 kB)
ERROR: Could not find a version that satisfies the requirement ankirspy (from versions: none)
ERROR: No matching distribution found for ankirspy
Traceback (most recent call last):
File “”, line 1, in
File “E:\Python\lib\subprocess.py”, line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘pip’, ‘install’, ‘mypy’, ‘anki’, ‘ankirspy’, ‘aqt’]’ returned non-zero exit status 1.

I’m new to using the Python console, but I have a basic understanding of what subprocess.check_call does; I just can’t figure out this error. I’m running Windows 10, and I’ve tried this with both Python 3.7.6 (PIP version 19.0.3) and Python 3.6.0 .

1 Like

Try running:

  1. subprocess.check_call(["python", "-m", "pip", "uninstall", "mypy", "anki", "ankirspy", "aqt"])
  2. subprocess.check_call(["python", "-m", "pip", "install", "mypy", "anki", "ankirspy", "aqt"])

Do you have pip installed? You can try installing it with subprocess.check_call(["python", "-m", "ensurepip"])

I have pip (20.1.1) installed, checking it in PyCharm works fine. Running those commands didn’t help any; it says mypy, anki, ankirspy, and aqt all weren’t installed, then gives me the same error.

Try install individually each one of the required modules:

  1. subprocess.check_call([“python”, “-m”, “pip”, “install”, “mypy”])
  2. subprocess.check_call([“python”, “-m”, “pip”, “install”, “anki”])
  3. subprocess.check_call([“python”, “-m”, “pip”, “install”, “ankirspy”])
  4. subprocess.check_call([“python”, “-m”, “pip”, “install”, “aqt”])

What is your Python version?

The file on PyPI requires a 64 bit build of Python. Perhaps you are using a 32 bit Python?

Getting a bit closer. I tried this with a Python 3.6.0 (64-bit) virtual environment, and mypy installs successfully, but I’m still getting the same error with anki, ankirspy, and aqt. My hunch is that there’s no release for these modules that’s compatible with Python 3.6.0 …

Can someone tell me what Python version they’re using that got it working?

Anki requires at least Python 3.7 to work: https://github.com/ankitects/anki/blob/master/README.development

1 Like

Great, that explains it. I tried this with Python 3.7 (32-bit), which is incompatible with PyPl, and Python 3.6 (64-bit), which is incompatible with Anki. Just got it working with Python 3.8.3 (64-bit).

Thanks for the help @dae and @addons_zz!

2 Likes

used this instead and its seems to work on my machine:
subprocess.check_call([“python3”, “-m”, “pip”, “install”, “mypy”, “anki”, “ankirspy”, “aqt”])