Skip to content

import worldometer error #7

Description

@viplazylmht

I have found a problem that is, I can't import worldometer to notebooks.

Env: anaconda3, WSL
Version: Python 3.8.3, worldometer-1.0.1

The full error response is:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/anaconda3/lib/python3.8/site-packages/worldometer/core.py in _get_html(self, url)
    233             self.__r = session.get(url, timeout=self.__timeout)
--> 234             self.__r.html.render(timeout=self.__timeout)
    235 

~/anaconda3/lib/python3.8/site-packages/requests_html.py in render(self, retries, script, wait, scrolldown, sleep, reload, timeout, keep_page)
    585 
--> 586         self.browser = self.session.browser  # Automatically create a event loop and browser
    587         content = None

~/anaconda3/lib/python3.8/site-packages/requests_html.py in browser(self)
    728             if self.loop.is_running():
--> 729                 raise RuntimeError("Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead.")
    730             self._browser = self.loop.run_until_complete(super().browser)

RuntimeError: Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead.

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-3-c4b22f2d5ddf> in <module>
----> 1 import worldometer

~/anaconda3/lib/python3.8/site-packages/worldometer/__init__.py in <module>
     82 
     83 from .core import Worldometer
---> 84 from .api import *

~/anaconda3/lib/python3.8/site-packages/worldometer/api.py in <module>
    106 
    107 
--> 108 __w = Worldometer()
    109 
    110 

~/anaconda3/lib/python3.8/site-packages/worldometer/core.py in __init__(self, timeout)
    179         self.__timeout = timeout
    180 
--> 181         self._metrics = self.collect_metrics()
    182 
    183     def __str__(self):

~/anaconda3/lib/python3.8/site-packages/worldometer/core.py in collect_metrics(self)
    298 
    299         if self.__r is None:
--> 300             html = self._get_html(url=URL)
    301         else:
    302             html = self.__r.html.raw_html

~/anaconda3/lib/python3.8/site-packages/worldometer/core.py in _get_html(self, url)
    237 
    238         except Exception as err:
--> 239             raise Exception(err)
    240 
    241     @staticmethod

Exception: Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead.

I thinks this is one of a limitation of WSL hence hope anyone find out the solution soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions