Selenium Path Doesn't make sense

Multi tool use


Selenium Path Doesn't make sense
Ran a quick Script
from selenium import webdriver
path = r"C:/Users/andre/Desktop/chromedriver.exe"
driver = webdriver.Chrome(path)
driver.get('https://www.google.ca')
Output is
andrefu@LAPTOP-1011FFMG:/mnt/c/Users/andre/Desktop/Pardee Lab$ python3 Scrape_RNAfold.py
Traceback (most recent call last):
File "/home/andrefu/anaconda3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/home/andrefu/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/home/andrefu/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/andre/Desktop/chromedriver.exe': 'C:/Users/andre/Desktop/chromedriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Scrape_RNAfold.py", line 7, in <module>
driver = webdriver.Chrome(path)
File "/home/andrefu/anaconda3/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/home/andrefu/anaconda3/lib/python3.6/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.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
My chromedriver.exe is in my Desktop So, I really don't know why its saying chromedriver isn't working.
I've tried different paths such as
path = 'C:UsersandreDesktopchromedriver.exe'
path = 'C:UsersandreDesktop'
path = 'C:/Users/andre/Desktop/chromedriver.exe'
path = 'C:/Users/andre/Desktop'
Even putting my chromedriver in the same folder as my code Scrape_RNAfold.py
Running it with the full path name and just the driver = webdriver.Chrome()
.
Scrape_RNAfold.py
driver = webdriver.Chrome()
I also tried it with the raw 'r' unicode before the string and with out it & using both single and double quotes. Could someone please help me identify where i'm going wrong?
driver = webdriver.Chrome()
@Andersson thanks for taking the time, in the original post you can see I tried that already. Here is my output
– Andre Fu
26 mins ago
No. I mean not in the same folder as your script, but in the same folder with
python3.exe
– Andersson
23 mins ago
python3.exe
@Andersson sorry about that, I'm using WSL so my python3.exe is all the way in my /home. Here is my output
– Andre Fu
13 mins ago
@Andersson I have no idea what putting that into my python3.exe did, but it keeps giving me the Invalid argument. Note: It doesn't let me do anything now, I tried
pip freeze | grep splinter
and its giving me an invalid argument! (oh no i don't know what I did....) I deleted chromedriver.exe from that folder now.– Andre Fu
9 mins ago
pip freeze | grep splinter
1 Answer
1
There seems to be some mismatch between the path seperator (i.e. /
) and the quotes (i.e. ""
)
/
""
You need to download the latest ChromeDriver from ChromeDriver - WebDriver for Chrome and store it anywhere within your system. As you are on Windows OS, unzip the binary and perform the following:
\
" "
" "
r
So your code block will be:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:UsersandreDesktopchromedriver.exe')
driver.get('https://www.google.ca')
Thanks for the response. I tried that before, sorry I didn't mention it. Here is my output You can see, exectuable_path isn't recognized as an argument. When removing executable_path, I get a similar error as before.
– Andre Fu
29 mins ago
Edit: Noticed I spelt executable wrong, changed it and I get the same error as before.
– Andre Fu
21 mins ago
Can you update the mail question with the error trace logs for further analysis?
– DebanjanB
16 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Try to put it in the same folder as Python3 executable and use as
driver = webdriver.Chrome()
– Andersson
30 mins ago