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

Sometimes unable to find chromedriver executable. #29

Open
pgooch opened this issue Feb 7, 2020 · 0 comments
Open

Sometimes unable to find chromedriver executable. #29

pgooch opened this issue Feb 7, 2020 · 0 comments

Comments

@pgooch
Copy link

pgooch commented Feb 7, 2020

python --version Python 3.8.1
The other two commands, , give me a 78: Function not implemented, which seems like it could be a problem but I'm not sure the best solution.

Expectation

I have built a super simple python script to run this and save the output to a file, that script is:

import os
import json

# This comes from SO, like all good code: https://stackoverflow.com/questions/4060221/how-to-reliably-open-a-file-in-the-same-directory-as-a-python-script
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))

# Super sketchy but I'm not really worried about my comcast account.
os.environ['XFINITY_USER'] = 'username';
os.environ['XFINITY_PASSWORD'] = 'password';

# This runs the scraper
from xfinity_usage.xfinity_usage import XfinityUsage
usageScraper = XfinityUsage(os.environ['XFINITY_USER'], os.environ['XFINITY_PASSWORD'], browser_name='chrome-headless')
usage = usageScraper.run()

# This saves the data to a file for future use.
with open(os.path.join(__location__, 'usage.raw.json.txt'), 'w') as save:
    json.dump(usage, save)

This runs great when I try and run it from iTerm, but fails when the system tries to run it automatically. This is the command I'm having the launchagent run

/Users/phillipgooch/.pyenv/shims/python /Users/phillipgooch/Development/internet-gauge-cluster/get-comcast-usage.py

That is the same python I am using in the terminal, the exact same command in fact down to the explicitly location of the python I'm trying to use. I've read that it's best not to mess with the mac internal python version and considering trying to fix this problem I just made things worse I'm all for keeping the stock version of of this. I would expect that if the command works in the standard terminal that the system would be able to run it just as easily.

Reality

Whenever I test the script with Lingon X (an application that gives the LaunchAgent plist a UI) I get the following error:

Traceback (most recent call last):
  File "/Users/phillipgooch/Development/internet-gauge-cluster/get-comcast-usage.py", line 18, in <module>
    usage = usageScraper.run()
  File "/Users/phillipgooch/.pyenv/versions/3.8.1/lib/python3.8/site-packages/xfinity_usage/xfinity_usage.py", line 122, in run
    self.browser = self.get_browser()
  File "/Users/phillipgooch/.pyenv/versions/3.8.1/lib/python3.8/site-packages/xfinity_usage/xfinity_usage.py", line 403, in get_browser
    browser = webdriver.Chrome(chrome_options=chrome_options)
  File "/Users/phillipgooch/.pyenv/versions/3.8.1/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Users/phillipgooch/.pyenv/versions/3.8.1/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

This is the same command the standard terminal call executes fine. I don't understand why it works in one location and not another.

I'm hoping you might have a solution for this that I can implement on my own end. I looked for but didn't see a way to provide it a direct path to the chromedriver.

I get that this is more of an issue with my machine and not your script, I'm just hoping someone might have some insight or a work around. I'm running a freshly installed OSX Catalina (just reinstalled because I had borked the system Python hard and was looking for an excuse to do it anyway). The stock Python has remained untouched and everything installed with brew.

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

1 participant