HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
349 stars 52 forks source link

FileNotFoundError: [WinError 2] The system cannot find the file specified #163

Closed Aragonski97 closed 8 months ago

Aragonski97 commented 8 months ago

Hi, while running a test example:

from arsenic.browsers import Firefox
from arsenic.services import Geckodriver
import asyncio

async def example():
    # Runs geckodriver and starts a firefox session
    async with get_session(Geckodriver(), Firefox()) as session:
          # go to example.com
          await session.get('random_url')
          # wait up to 5 seconds to get the h1 element from the page
          h1 = await session.wait_for_element(5, 'h1')
          # print the text of the h1 element
          print(await h1.get_text())
asyncio.run(example())`

I get the following error:
`C:\Users\User\PycharmProjects\Project\venv\Scripts\python.exe C:\Users\User\PycharmProjects\Project\testing.py 
Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\Project\testing.py", line 15, in <module>
    asyncio.run(example())
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "C:\Users\User\PycharmProjects\Project\testing.py", line 8, in example
    async with get_session(Geckodriver(), Firefox()) as session:
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\arsenic\__init__.py", line 16, in __aenter__
    self.session = await start_session(self.service, self.browser, self.bind)
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\arsenic\__init__.py", line 28, in start_session
    driver = await service.start()
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\arsenic\services.py", line 105, in start
    await self._check_version()
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\arsenic\services.py", line 86, in _check_version
    output = await impl.run_process([self.binary, "--version"])
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\arsenic\subprocess.py", line 43, in run_process
    process = await asyncio.create_subprocess_exec(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\subprocess.py", line 236, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1676, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 394, in _make_subprocess_transport
    transp = _WindowsSubprocessTransport(self, protocol, args, shell,
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 890, in _start
    self._proc = windows_utils.Popen(
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_utils.py", line 153, in __init__
    super().__init__(args, stdin=stdin_rfd, stdout=stdout_wfd,
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Process finished with exit code 1

Any and all suggestions welcome.

ojii commented 8 months ago

arsenic was unable to find geckodriver.exe in the path. make sure it's installed and findable, or pass the binary path explicitly to Geckodriver

Aragonski97 commented 8 months ago

Thanks @ojii . I got one more if you have the time. Sorry to bother with this, I'm having a really hard time. Running the same example gives me: from pyee.asyncio import AsyncIOEventEmitter ModuleNotFoundError: No module named 'pyee.asyncio' Which is very odd because pyee.asyncio clearly exists in pyee directory in site-packages. I downloaded playwright and installed it, but it's giving me the same error.

dimaqq commented 8 months ago

One thing to note is that playwright and arsenic are alternatives. It would be rather unusual to use both at the same time.

Aragonski97 commented 8 months ago

@dimaqq Understood. I think I was looking at the wrong Stack Overflow thread. Nevertheless, I tried reinstalling pyee manually, arsenic as well, but it didn't help the issue. Wondering where the problem might be.

ojii commented 8 months ago

pyee is not used by arsenic at all, whatever issue you're having is unrelated to this project.