sCuper
sCuper

Reputation: 91

chromedriver.exe is in PATH, but selenium gives me an error

I'm using the bash shell in Windows 10 which makes everything feel like a unix system and I'm trying to run the following python2.7 code:

    from selenium import webdriver

    driver = webdriver.Chrome()

However, I get the following error code:

Traceback (most recent call last):
File "seleniumtest.py", line 3, in <module>
driver = webdriver.Chrome()
File "/home/eirik/.local/lib/python2.7/sitepackages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/home/eirik/.local/lib/python2.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.com/a/chromium.org/chromedriver/home

By googeling I found that this was a quite common problem and that I had to download the chromedriver and specifiy where it was. So I changed the above to this:

    driver = webdriver.Chrome(executable_path = r'/path/to/chromedriver.exe')

But I got the same result. After that I went into Windows Enviroment Variable and made sure that the folder where I put the chromedriver was read as PATH. It was.

To check if this PATH was also read by the bash shell, I wrote the following:

    echo $PATH | tr ":" "\n" | nl

In my bash shell. This gave the output:

 1  /home/eirik/bin
 2  /home/eirik/.local/bin
 3  /usr/local/sbin
 4  /usr/local/bin
 5  /usr/sbin
 6  /usr/bin
 7  /sbin
 8  /bin
 9  /usr/games
10  /usr/local/games
11  /mnt/c/webdriver
12  /mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common
13  /mnt/c/ProgramData/Oracle/Java/javapath
14  /mnt/c/Program Files (x86)/Intel/iCLS Client
15  /mnt/c/Program Files/Intel/iCLS Client
16  /mnt/c/Windows/System32
17  /mnt/c/Windows
18  /mnt/c/Windows/System32/wbem
19  /mnt/c/Windows/System32/WindowsPowerShell/v1.0
20  /mnt/c/Program Files (x86)/GtkSharp/2.12/bin
21  /mnt/c/Program Files (x86)/Skype/Phone
22  /mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL
23  /mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL
24  /mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT
25  /mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT
26  /mnt/c/Windows/System32
27  /mnt/c/Windows
28  /mnt/c/Windows/System32/wbem
29  /mnt/c/Windows/System32/WindowsPowerShell/v1.0
30  /mnt/c/Program Files (x86)/Windows Live/Shared
31  /mnt/c/Program Files/MiKTeX 2.9/miktex/bin/x64
32  /mnt/c/Users/Hauge/AppData/Local/Microsoft/WindowsApps
33  /snap/bin
34  /mnt/c/webdriver/

Where /mnt/c/webdriver/ is where the chromedriver.exe file is located. I am at a loss to what to do next. I have tried everything I could find, but I can't seem to get selenium to accept my chromedriver. Does anybody have any idea of what to do?

Upvotes: 0

Views: 3054

Answers (2)

sCuper
sCuper

Reputation: 91

I found a solution! By putting the chromedriver.exe file in the same folder as the script and running it with ./chromedriver.exe the script was able to access it from that folder.

Upvotes: 2

Mike Peder
Mike Peder

Reputation: 738

I believe your issue is that you are trying to have your Ubuntu subsystem access a Windows driver when it needs a Linux driver. Download the chromedriver for linux64 and ensure that it is in your path.

Upvotes: 0

Related Questions