ManicJamie / speedruncompy

A python wrapper for speedrun.com's v2 API.
GNU Lesser General Public License v2.1
7 stars 2 forks source link

Importing GetGameLeaderboard2 gives "RuntimeError: no running event loop" #6

Open jsmithdataanalytics opened 4 days ago

jsmithdataanalytics commented 4 days ago

Am I missing something?

Python version: 3.12.3 OS: Ubuntu 24.04.1 LTS

from speedruncompy.endpoints import GetGameLeaderboard2
Traceback (most recent call last):
  File "/snap/pycharm-community/407/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
           ^^^^^^
  File "<input>", line 1, in <module>
  File "/snap/pycharm-community/407/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/james/.local/share/virtualenvs/srl-fyk6OVgP/lib/python3.12/site-packages/speedruncompy/__init__.py", line 1, in <module>
    from .endpoints import *  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/pycharm-community/407/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/james/.local/share/virtualenvs/srl-fyk6OVgP/lib/python3.12/site-packages/speedruncompy/endpoints.py", line 1, in <module>
    from .api import BasePaginatedRequest, GetRequest, PostRequest, SpeedrunComPy
  File "/snap/pycharm-community/407/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/james/.local/share/virtualenvs/srl-fyk6OVgP/lib/python3.12/site-packages/speedruncompy/api.py", line 68, in <module>
    _default = SpeedrunComPy()
               ^^^^^^^^^^^^^^^
  File "/home/james/.local/share/virtualenvs/srl-fyk6OVgP/lib/python3.12/site-packages/speedruncompy/api.py", line 24, in __init__
    self.cookie_jar = aiohttp.CookieJar()
                      ^^^^^^^^^^^^^^^^^^^
  File "/home/james/.local/share/virtualenvs/srl-fyk6OVgP/lib/python3.12/site-packages/aiohttp/cookiejar.py", line 89, in __init__
    super().__init__(loop=loop)
  File "/home/james/.local/share/virtualenvs/srl-fyk6OVgP/lib/python3.12/site-packages/aiohttp/abc.py", line 172, in __init__
    self._loop = loop or asyncio.get_running_loop()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
YummyBacon5 commented 4 days ago

This is an issue with the version installed from PyPi. As that one is outdated compared to the one on GitHub.

I would uninstall that version and instead install the one from the current GitHub repo. Or from my #5 pull request because it has slightly more endpoints and kwargs added.

pip uninstall speedruncompy && pip install git+https://github.com/YummyBacon5/speedruncompy.git

or

pip uninstall speedruncompy && pip install git+https://github.com/ManicJamie/speedruncompy.git