NotImplementedError
Traceback:
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py”, line 584, in _run_script
exec(code, module.dict)
File “C:\Users\user\Desktop\AI\Module 4\sentimentE.py”, line 163, in
sentiment.run()
File “C:\Users\user\Desktop\AI\Module 4\sentimentE.py”, line 130, in run
docs = loader.load()
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\langchain_core\document_loaders\base.py”, line 29, in load
return list(self.lazy_load())
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\langchain_community\document_loaders\chromium.py”, line 78, in lazy_load
html_content = asyncio.run(self.ascrape_playwright(url))
File “d:\Users\user\anaconda3\envs\tbot\lib\asyncio\runners.py”, line 44, in run
return loop.run_until_complete(main)
File “d:\Users\user\anaconda3\envs\tbot\lib\asyncio\base_events.py”, line 647, in run_until_complete
return future.result()
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\langchain_community\document_loaders\chromium.py”, line 54, in ascrape_playwright
async with async_playwright() as p:
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\playwright\async_api_context_manager.py”, line 46, in aenter
playwright = AsyncPlaywright(next(iter(done)).result())
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\playwright_impl_connection.py”, line 247, in run
await self._transport.connect()
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\playwright_impl_transport.py”, line 132, in connect
raise exc
File “d:\Users\user\anaconda3\envs\tbot\lib\site-packages\playwright_impl_transport.py”, line 120, in connect
self._proc = await asyncio.create_subprocess_exec(
File “d:\Users\user\anaconda3\envs\tbot\lib\asyncio\subprocess.py”, line 236, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
File “d:\Users\user\anaconda3\envs\tbot\lib\asyncio\base_events.py”, line 1676, in subprocess_exec
transport = await self._make_subprocess_transport(
File “d:\Users\user\anaconda3\envs\tbot\lib\asyncio\base_events.py”, line 498, in _make_subprocess_transport
raise NotImplementedError
import streamlit as st
from playwright.async_api import async_playwright
import asyncio
async def run_automation():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
await page.goto('https://docs.streamlit.io/')
title = await page.title()
await browser.close()
return title
def run_async_function():
return asyncio.run(run_automation())
if __name__ == "__main__":
if st.button('Run Automation'):
result_placeholder = st.empty()
result_placeholder.text("Running automation...")
result = run_async_function()
result_placeholder.text(result)
Error:
NotImplementedError
Traceback:
File "C:\Users\Gabriel\anaconda3\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 584, in _run_script
exec(code, module.__dict__)
File "C:\Users\Gabriel\OneDrive\Documentos\GitHub\dash_streamlit\teste.py", line 21, in <module>
result = run_async_function()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\OneDrive\Documentos\GitHub\dash_streamlit\teste.py", line 15, in run_async_function
return asyncio.run(run_automation())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\OneDrive\Documentos\GitHub\dash_streamlit\teste.py", line 6, in run_automation
async with async_playwright() as p:
File "C:\Users\Gabriel\anaconda3\Lib\site-packages\playwright\async_api\_context_manager.py", line 46, in __aenter__
playwright = AsyncPlaywright(next(iter(done)).result())
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\site-packages\playwright\_impl\_transport.py", line 120, in connect
self._proc = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\asyncio\subprocess.py", line 221, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\asyncio\base_events.py", line 1694, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabriel\anaconda3\Lib\asyncio\base_events.py", line 502, in _make_subprocess_transport
raise NotImplementedError
Out of curiosity, have you considered switching to the synchronous version of Playwright? This can help avoid using asyncio and simplify subprocess handling.
Thanks for your suggestion! While I haven’t explored the synchronous version of Playwright yet, I’ll definitely look into it further to see if it’s a good fit for my needs.
I managed to get around the error by using the Selenium library (I’m not very used to it, but with your tip I will certainly switch to synchronous).
However, in this case it is just an example where I run a streamlit dash. The aim is to provide a frontent for users to do webscrapping using my computer as a host.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.