Forums

'chromedriver' executable needs to be in PATH

Hi,

I believe headless chrome was enabled on my account. I've upgraded selenium and am running this simple test script:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

try:
    browser.get("https://www.google.com")
    print("Page title was '{}'".format(browser.title))

finally:
    browser.quit()

However, I get the following error:

Traceback (most recent call last):
  File "/home/manwithfewneeds/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
  File "/usr/lib/python3.7/subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1499, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/manwithfewneeds/.local/lib/python3.7/test_selenium.py", line 6, in <module>
    browser = webdriver.Chrome(options=chrome_options)
  File "/home/manwithfewneeds/.local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", 
line 73, in __init__
    self.service.start()
  File "/home/manwithfewneeds/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", 
line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. 
Please see https://sites.google.co
m/a/chromium.org/chromedriver/home

It doesn't appear that chromedriver is in my PATH (at least I can't find it in the file system). Any help please?

It looks like we may need to upgrade your system image to one that provides Chromedriver -- that will basically upgrade the version of the operating system your account uses. All of your files and data will be kept safe, but the versions of Python installed and the pre-installed packages will be upgraded.

One word of warning, though -- because of the changes to the point releases of Python (eg. 3.7.0 to 3.7.5), any virtualenvs you have might break -- and if you're not using virtualenvs, the pre-installed Python modules will be upgraded so that might break any code you have that relies on the old installed versions.

If you're happy for us to switch you over despite that, then let us know.

Hi there. I seem to be having the same issue. I've attempted to install chromedriver in the site packages, but am still receiving the same error as above. The code runs fine on my PC.

Traceback (most recent call last): File "/home/michaelturner008/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "/usr/lib/python3.8/subprocess.py", line 854, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'lib/chromedriver' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/michaelturner008/.virtualenvs/through-the-marshes/bid-fta-scrape.py", line 293, in <module> main() File "/home/michaelturner008/.virtualenvs/through-the-marshes/bid-fta-scrape.py", line 22, in main browser = set_up_browser() File "/home/michaelturner008/.virtualenvs/through-the-marshes/bid-fta-scrape.py", line 288, in set_up_browser browser = webdriver.Chrome('lib/chromedriver', options=options, desired_capabilities=caps) File "/home/michaelturner008/.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in init self.service.start() File "/home/michaelturner008/.local/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

@michaelturner008 It looks like you are already in contact with us over support email.

apologies! I hadn't seen the email - I'll continue the conversation there.

Hi @giles. Can you please also update me to use chromedriver? I understand this changes the image, and approve of you to change it. Thank you!

@LeonardPetracci You no longer need to ask to have your system image changed -- you can change it yourself from the "Account" page. There's more information on this help page: https://help.pythonanywhere.com/pages/ChangingSystemImage

HI! I have same error message below. Would you help me upgrading my system image to one that provides Chromedriver? Thank you!


selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Your system image has chromedriver. What is in your PATH?

Hi , tried changing that system image but it looks like i have the most recent one. Is there any other way to fix this error? Any help would be appreciated <3

What do you see if you look at your system path -- that is,

echo $PATH

...in a Bash console?

that's what I got from typing the above in my bash console : /home/my_username/.local/bin:/usr/local/julia-1.6.1/bin:/home/my_username/.local/bin:/usr/local/julia-1.6.1/bin:/usr/local/sbin:/usr/local/bin:/usr/ sbin:/usr/bin:/sbin:/bin

That looks like it should be working, so my guess is that you are specifying the path to chromedriver in your code and pointing to a place where is isn't. What happens when you use the example code at the top of this topic in a new console?

the example code used above seem to be working completly fine when I run it on my bash console .

Great! Then you can use the example to modify the code you want to run so that it follows the same pattern.

That's what I did . Thank you for taking the time to respond and trying to help me , I appreciate that <3 I just have never worked with linux neither have I worked with pythonanywhere before , All i did was pasting the script i had written on vscode here on pythonanywhere and pressed run , after that error i decided to download a webdriver that is used for linux and then getting it's path but that didn't work either . Anyways.Thank you.

Glad to hear that you are progressing.

Hello Everyone,

I have the same issue and I would like to request for your help.

I am working to deploy a python flask app--containing selenium/bs4 python code to python anywhere however it seems that there is something wrong with the driver.

***I've tried for chrome already:

path = Service("/home/mariondeguzman/flask_app/chromedriver")
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(service=path, options=options)

***Also for firefox:

path = Service("/home/mariondeguzman/flask_app/geckodriver")
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
service = Service(path)
driver = Firefox(service=service, options=options)

But both of them won't work and would have some form of "driver needs to be on PATH" variation of errors.

Thanks in advance for your help.

There's already chromedirever installed, you don't need to upload another one. Also -- selenium will most probably not work on a free account, due to internet restrictions, and we don't recommend using it in a web app.

Hi @pafk, thanks for the feedback.

"There's already chromedirever installed, you don't need to upload another one." --For this, does it mean pythonanywhere has its own chromedriver? And what linux dir is it located?

"Also -- selenium will most probably not work on a free account, due to internet restrictions, " --For this, what subscription plan is recommended on this kind of application?

"and we don't recommend using it in a web app." --Hmm, thanks for the inputs. I'm thinking of deploying my selenium scraping tool with a front end tool so that I can allow my team mates use it. If it's not recommended on a web app, do you have recommendation how can a selenium tool be used by multiple users?

Thanks in advance for your answers.

--Marion

  1. It's on the path. You do not need to specify the path.
  2. Any paid account will have unrestricted internet access.
  3. See https://help.pythonanywhere.com/pages/AsyncInWebApps/