Open apitofme opened 9 hours ago
Just to confirm, what command did you run to install this? You've installed opentdb, a completely different package, by mistake. Whether you've typo'd or whether something really weird has happened I'm not sure, but either way, it's not opentriviadb
you have on your system.
This is what I get when doing it on 3.13 (I haven't declared it supports 3.13 yet):
❯ pip install opentriviadb
ERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.7.0,<3.13
ERROR: Could not find a version that satisfies the requirement opentriviadb (from versions: none)
ERROR: No matching distribution found for opentriviadb
And on 3.12:
❯ pip install opentriviadb
...
Installing collected packages: propcache, multidict, idna, frozenlist, attrs, aiohappyeyeballs, yarl, aiosignal, aiohttp, opentriviadb
Successfully installed aiohappyeyeballs-2.4.3 aiohttp-3.10.10 aiosignal-1.3.1 attrs-24.2.0 frozenlist-1.4.1 idna-3.10 multidict-6.1.0 opentriviadb-0.1.0 propcache-0.2.0 yarl-1.16.0
❯ py -c "from opentriviadb import Category; print(Category)"
<enum 'Category'>
Please take this as "being brief" rather than being blunt...
from opentriviadb import Category
-- this alone appears to have two issues when I attempted to copy this example:i. The package name is incorrect:
-- "opentdb" however does work!
ii. The module name is inccorrect:
-- "categories" works!
client.py
file does not match the one (linked above) here on GitHub. Whilst trying to confirm the package was installed and available I opened a Python interactive shell prompt and ranhelp('modules opentdb')
to confirm the package was available. I then ran justhelp('opentdb')
which resulted in an error, (to simplify) the important part of which is:-- Opening the file and correcting line #5 to read
from html.parser import HTMLParser
fixed that issue!However later in the file you have the line
unescape = HTMLParser().unescape
which also causes an error, since HTMLParser does not have an attribute called 'unescape' (or a method for that matter), the basehtml
module has the unescape method on it. (Perhaps a Python version issue?)client.py
(including the one previously mentioned above) seem to all be using theasync
syntax, as does the main usage example on the homepage of this project, e.g.async with Client() as client:
but this causes another error message:async with Client() as client: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'async with' outside async function
-- I am not familiar with the asyncio library so I could attribute this to "rookie error", but if so then perhaps the example should be more comprehensive so as to demonstrate it's usage in a way that works when copied 'verbatim' as it were.As such, I am so far unable to get this package to function in any meaningful way. Even when creating a
Client
instance without usingasync
I am unable to yield any questions following (and adapting) the examples given...dir()
I can see:['_Client__API_BASEURL', '_Client__API_ENDPOINT', '_Client__API_TOKEN', '_Client__API_TOKEN_ENDPOINT', '_Client__apiRequest', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', 'getCategories', 'getQuestions', 'getToken', 'printToken']
I am confused because the available public methods (listed last) do not match up to the code here on GitHub, e.g. the request_token method.
Note: I installed this package from PyPI using
pip
, which reports the same version number as here on GitHub.