Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: asyncio.run() cannot be called from a running event loop #771

Open
boral opened this issue Oct 28, 2024 · 3 comments
Open

Comments

@boral
Copy link

boral commented Oct 28, 2024

While running Readme example facing this

'''
result = smart_scraper_graph.run()
--- Executing Fetch Node ---
--- (Fetching HTML from: https://scrapegraphai.com/) ---
Traceback (most recent call last):

Cell In[5], line 1
result = smart_scraper_graph.run()

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\graphs\smart_scraper_graph.py:114 in run
self.final_state, self.execution_info = self.graph.execute(inputs)

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\graphs\base_graph.py:263 in execute
return self._execute_standard(initial_state)

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\graphs\base_graph.py:184 in _execute_standard
raise e

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\graphs\base_graph.py:168 in _execute_standard
result = current_node.execute(state)

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\nodes\fetch_node.py:126 in execute
return self.handle_web_source(state, source)

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\nodes\fetch_node.py:284 in handle_web_source
document = loader.load()

File ~\anaconda3\envs\test\Lib\site-packages\langchain_core\document_loaders\base.py:31 in load
return list(self.lazy_load())

File ~\anaconda3\envs\test\Lib\site-packages\scrapegraphai\docloaders\chromium.py:111 in lazy_load
html_content = asyncio.run(scraping_fn(url))

File ~\anaconda3\envs\test\Lib\asyncio\runners.py:186 in run
raise RuntimeError(

RuntimeError: asyncio.run() cannot be called from a running event loop
'''

@VinciGit00
Copy link
Collaborator

Are you using collab?

@boral
Copy link
Author

boral commented Oct 28, 2024

No Spyder

@f-aguzzi
Copy link
Member

Take a look at the first two code blocks in the Colab example, the ones about nest_asyncio. Even though you're using Spyder, it's still a Jupyter Notebook, so the fix should be the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants