amosbastian / understat

An asynchronous Python package for https://understat.com/.
MIT License
157 stars 30 forks source link

error messages #9

Closed hayilmaz closed 5 years ago

hayilmaz commented 5 years ago

ran the following code:

async def main(): async with aiohttp.ClientSession() as session: understat = Understat(session) player = await understat.get_league_players( "epl", 2018, player_name="Paul Pogba", team_title="Manchester United" ) print(json.dumps(player))

loop = asyncio.get_event_loop() loop.run_until_complete(main())

got the following message:

RuntimeError Traceback (most recent call last)

in 10 11 loop = asyncio.get_event_loop() ---> 12 loop.run_until_complete(main()) ~/anaconda3/lib/python3.7/asyncio/base_events.py in run_until_complete(self, future) 569 future.add_done_callback(_run_until_complete_cb) 570 try: --> 571 self.run_forever() 572 except: 573 if new_task and future.done() and not future.cancelled(): ~/anaconda3/lib/python3.7/asyncio/base_events.py in run_forever(self) 524 self._check_closed() 525 if self.is_running(): --> 526 raise RuntimeError('This event loop is already running') 527 if events._get_running_loop() is not None: 528 raise RuntimeError( RuntimeError: This event loop is already running [{"id": "1740", "player_name": "Paul Pogba", "games": "35", "time": "3013", "goals": "13", "xG": "15.87753972876817", "assists": "9", "xA": "5.186745170503855", "shots": "105", "key_passes": "55", "yellow_cards": "6", "red_cards": "0", "position": "M S", "team_title": "Manchester United", "npg": "6", "npxG": "8.265851370058954", "xGChain": "21.12592289596796", "xGBuildup": "11.593518570065498"}]
amosbastian commented 5 years ago

Did you figure it out?

hayilmaz commented 5 years ago

It works differently in two different platforms.

In anaconda/jupyter it gives me error. In VSCode python, I don’t get the error message.

On Sep 23, 2019, at 3:01 PM, Amos Bastian notifications@github.com wrote:

Did you figure it out?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/amosbastian/understat/issues/9?email_source=notifications&email_token=AI56YAMOMMR7AHUGYZCSF33QLE4E3A5CNFSM4IZPGUK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7MM7QY#issuecomment-534302659, or mute the thread https://github.com/notifications/unsubscribe-auth/AI56YANDY7MLUYJMJWPWJFLQLE4E3ANCNFSM4IZPGUKQ.

gringorichards commented 5 years ago

If it's juypter notebook in ananconda, then put these lines at the top to fix that.

import nest_asyncio nest_asyncio.apply()

hayilmaz commented 5 years ago

Great

Thank you

H. Adem Yilmaz

On Sep 25, 2019, at 1:31 PM, Tom notifications@github.com wrote:

 If it's juypter notebook in ananconda, then put these lines at the top to fix that.

import nest_asyncio nest_asyncio.apply()

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.