By Akendo

2011-11-24 10:57:00 8 Comments

I ran into a problem while working with Selenium. For my project, I have to use Chrome. However, I can't connect to that browser after launching it with Selenium.

For some reason, Selenium can't find Chrome by itself. This is what happens when I try to launch Chrome without including a path:

Traceback (most recent call last):
  File "./", line 73, in <module>
    browser = webdriver.Chrome() # Get local session of chrome
  File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/", line 46, in __init__
  File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/", line 58, in start
    and read up at")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.                 Please download from                and read up at'

To solve this problem, I then included the Chromium path in the code that launches Chrome. However, the interpreter fails to find a socket to connect to:

Traceback (most recent call last):
  File "./", line 73, in <module>
    browser = webdriver.Chrome('/usr/bin/chromium') # Get local session of chrome
  File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/", line 46, in __init__
  File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/", line 64, in start
    raise WebDriverException("Can not connect to the ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'Can not connect to the ChromeDriver'

I also tried solving the problem by launching chrome with:

chromium --remote-shell-port=9222

However, this did not work either.

PS. Here's some information about my system:

www-client: chromium 15.0.874.121  
dev-lang:   python 2.7.2-r3 Selenium 2.11.1  
OS:         GNU/Linux Gentoo Kernel 3.1.0-gentoo-r1


@Vicky 2014-06-23 11:04:36

For Linux

  1. Check you have installed latest version of chrome brwoser-> chromium-browser -version
  2. If not, install latest version of chrome sudo apt-get install chromium-browser
  3. get appropriate version of chrome driver from here
  4. Unzip the
  5. Move the file to /usr/bin directory sudo mv chromedriver /usr/bin
  6. Goto /usr/bin directory cd /usr/bin
  7. Now, you would need to run something like sudo chmod a+x chromedriver to mark it executable.
  8. finally you can execute the code.

    from selenium import webdriver
    driver = webdriver.Chrome()
    print driver.page_source.encode('utf-8')

@Imran 2015-03-09 20:55:58

Very nice! One note: I was only able to get this to work with the 32-bit chromedriver although I am running 64-bit linux.

@Arpad Horvath 2016-06-19 06:37:35

On Ubuntu (14.04) you can install chromium-chromdriver package (e.g. with apt-get) and add the path of the chromedriver file to the PATH shell variable PATH="${PATH}":/usr/lib/chromium-browser/ If you add this to your .bashrc, you won't need to set it each time you want to test with selenium.

@holzkohlengrill 2016-11-08 22:20:01

actually this answer should have a lot more upvotes. basically this is the way to go for every driver like the geckodriver.

@Vicky 2016-11-11 05:25:59

Thank you guys for upvotes and valuable comments.

@Vaibhav Maheshwari 2018-07-24 14:58:58

My chromium-browser version is mentioned as (Chromium 67.0.3396.99 Built on Ubuntu , running on Ubuntu 16.04) but the link only has versions as 2.0-2.9. Need some help.

@Abdul Majeed 2014-09-23 06:16:02

For windows

Download ChromeDriver from this direct link OR get the latest version from this page.

Paste the chromedriver.exe file in your C:\Python27\Scripts folder.

This should work now:

from selenium import webdriver
driver = webdriver.Chrome()

@bnrfly 2017-03-09 01:39:21

Thanks, that's worked for me

@Ripon Al Wasim 2017-07-24 12:47:05

There are 2 ways to run Selenium python tests in Google Chrome. I'm considering Windows (Windows 10 in my case):

Prerequisite: Download the latest Chrome Driver from:

Way 1:

i) Extract the downloaded zip file in a directory/location of your choice
ii) Set the executable path in your code as below:

self.driver = webdriver.Chrome(executable_path='D:\Selenium_RiponAlWasim\Drivers\chromedriver_win32\chromedriver.exe')

Way 2:

i) Simply paste the chromedriver.exe under /Python/Scripts/ (In my case the folder was: C:\Python36\Scripts)
ii) Now write the simple code as below:

self.driver = webdriver.Chrome()

@tyrantqiao 2017-06-10 05:22:19

For Windows' IDE:

If your path doesn't work, you can try to add the chromedriver.exe to your project, like in this project structure.


Then you should load the chromedriver.exe in your main file. As for me, I loaded the driver.exe in

def get_chrome_driver():
return webdriver.Chrome("..\\content\\engine\\chromedriver.exe",

.. means's upper directory

. means the directory where the is located

Hope this will be helpful.

@Jachin 2012-01-20 19:30:37

Mac OSX only

An easier way to get going (assuming you already have homebrew installed, which you should, if not, go do that first and let homebrew make your life better) is to just run the following command:

brew install chromedriver

That should put the chromedriver in your path and you should be all set.

@Akendo 2012-07-18 13:03:08

This may work for Mac, but i'm using Gentoo/Linux.

@Freddy 2016-02-16 16:50:05

Thank you. This worked for me (on a Mac).

@wyx 2016-09-10 15:11:48

It can't work on Mac. selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

@Jachin 2016-09-14 01:53:32

@wyx Your environment might not be setup right. Try running brew doctor and see if that finds anything.

@User 2016-11-21 02:40:23

This is one of those warm and fuzzy moments when you're just happy that you have a Mac. So easy.

@RHSMan 2017-11-28 15:30:44

HEART! I love brew

@user2253967 2013-04-07 10:54:56

For windows, please have the chromedriver.exe placed under <Install Dir>/Python27/Scripts/

@Gaurav Jain 2014-01-13 12:05:30

and where to put in ubuntu ? int /usr/lib/ or somewhere else?

@Qwerty 2014-08-29 09:50:19

Having the file in PATH wasn't enough, putting it to /Scripts/ where the is worked.

@Corey Goldberg 2017-12-20 15:54:44

putting it anywhere on your PATH works just fine.

@adam goucher 2011-11-24 15:07:57

You need to make sure the standalone ChromeDriver binary (which is different than the Chrome browser binary) is either in your path or available in the environment variable.

see for full information on how wire things up.


Right, seems to be a bug in the Python bindings wrt reading the chromedriver binary from the path or the environment variable. Seems if chromedriver is not in your path you have to pass it in as an argument to the constructor.

import os
from selenium import webdriver

chromedriver = "/Users/adam/Downloads/chromedriver"
os.environ[""] = chromedriver
driver = webdriver.Chrome(chromedriver)

@Akendo 2011-11-24 15:56:18

Sorry forget to mention that. I got this link.

@UberNeo 2013-12-18 02:38:02

Tried the Chromedriver instead of Firefox Webdriver.. almost 3 times performance gain ..

@TheRookierLearner 2014-03-14 04:33:19

Also, just want to mention that the argument passed to the constructor is the path to ChromeDriver binary and not the directory containing the ChromeDriver binary (wasted the past half an hour figuring out what was going wrong).

Related Questions

Sponsored Content

26 Answered Questions

55 Answered Questions

[SOLVED] Calling an external command in Python

25 Answered Questions

[SOLVED] Is there a way to run Python on Android?

15 Answered Questions

[SOLVED] What are metaclasses in Python?

3 Answered Questions

[SOLVED] In Python, how to check if Selenium WebDriver has quit or not?

  • 2017-10-07 11:35:35
  • Kushagra Aggarwal
  • 1336 View
  • 0 Score
  • 3 Answer
  • Tags:   python selenium

1 Answered Questions

10 Answered Questions

1 Answered Questions

0 Answered Questions

Error while trying to open chrome python-selenium

Sponsored Content