[Python] Why can't I log into duolingo-api in python with duolingo.Duolingo('username',...

Discussão em 'Python' iniciado por Stack, Fevereiro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to access my duolingo data via scripting, and found duolingo-api. https://pypi.org/project/duolingo-api/ https://github.com/KartikTalwar/Duolingo

    I followed their installtion and usage directions in the documentation, but consistently get the same error when trying to log in.

    This post seemed promising, but I couldn't figure out how to apply it to my case. Login into Duolingo using Python Requests

    install via bash: $ pip install duolingo-api

    python script:

    import duolingo
    lingo = duolingo.Duolingo('kartik', 'my password')


    the error:

    Traceback (most recent call last):
    File "/home/"<my-current-directory>"/duolingo/lib64/python3.11/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib64/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/"<my-current-directory>"/duolingo/tmp.py", line 2, in <module>
    lingo = duolingo.Duolingo('usrname','password')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/"<my-current-directory>"/duolingo/lib64/python3.11/site-packages/duolingo.py", line 66, in __init__
    self._login()
    File "/home/"<my-current-directory>"/duolingo/lib64/python3.11/site-packages/duolingo.py", line 105, in _login
    attempt = request.json()
    ^^^^^^^^^^^^^^
    File "/home/"<my-current-directory>"/duolingo/lib64/python3.11/site-packages/requests/models.py", line 978, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
    requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


    I tried analyzing the error and the source code, but being new to python and web requests, I couldn't make sense of it. I have also tried installing globally, and in a virtual environment, on a slackware, arch and 2 windows machines with the same result. I can't find any information on this package online other than its own documentation, and can't figure out what to do. Any help would be greatly appreciated. Thank you!

    Continue reading...

Compartilhe esta Página