lk3de / impftermin-checker

Search Impftermine and Vermittlungscodes in Germany automatically
GNU General Public License v3.0
21 stars 9 forks source link

Can't run via PM2 #3

Closed LuisMartinSchick closed 3 years ago

LuisMartinSchick commented 3 years ago

Hello - love this project!

While running the project manually, it worked flawlessly - however when I tried to manage it via PM2, I started to run into issues. (Ran on a VM and my desktop)

The error code was the following:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python39\lib\subprocess.py", line 1416, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Impfterminchecker\impftermin_checker.py", line 280, in <module>
    driver = webdriver.Firefox(options=options, firefox_profile=profile)
  File "C:\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

As this only happened in PM2 and PyCharm, I started digging around and found a fix (for windows at least): You need to define the geckodriver executable variable directly (set the parameter executable_path when declaring the webdriver) and ideally have geckodriver inside the project to avoid permission issues.

I have implemented this in my fork and can merge it into your repository, if you wish.

lk3de commented 3 years ago

Hi there :)

I'm not familiar with PM2, so I'm glad you could solve the issue by yourself (at least partly)! 🙂 Thanks for sharing your experience - feel free to create a pull request! However, I'd prefer not to include the binary .exe file directly into this repo, as this would be a Windows-only solution, leaving other operating systems out. Furthermore, I don't know if that would be even allowed from a legal point of view (geckodriver is licensed under MPLv2, I put mine under GPLv3), and I don't want to get into trouble here. 😉