This question already has answers here:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chrome
(1 answer)
WebDriverException: Message: 'chromedriver' executable needs to be in PATH while setting UserAgent through Selenium Chromedriver python
(1 answer)
Error Message: 'chromedriver' executable needs to be PATH
(2 answers)
Closed 2 years ago.
Traceback (most recent call last):
File "/Applications/project bitcoin/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in init
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/paulndam/Downloads/chromedriver 2/chromedriver 2.exe': 'C:/Users/paulndam/Downloads/chromedriver 2/chromedriver 2.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/project bitcoin/Browser Automation.py", line 3, in
browser = webdriver.Chrome('C:/Users/paulndam/Downloads/chromedriver 2/chromedriver 2.exe')
File "/Applications/project bitcoin/venv/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in init
self.service.start()
File "/Applications/project bitcoin/venv/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 2.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
If you are creating a Chrome web driver then you need to put the path of the ChromeDriver in the first parameter: browser = webdriver.Chrome(CHROMEDRIVER_PATH) where CHROMEDRIVER_PATH is a variable containing the path.
Related
I have an EC2 machine from AWS with ARM flavour. I installed Python 3, and then used pip3 to install Selenium. I then downloaded the Linux version of chrome driver from here, unzipped it and kept the chromedriver file in Desktop. When I try to run code like this:
driver = webdriver.Chrome('/home/ec2-user/Desktop/chromedriver')
I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/.local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
service_log_path, service, keep_alive)
File "/home/ec2-user/.local/lib/python3.7/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
self.service.start()
File "/home/ec2-user/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
creationflags=self.creationflags)
File "/usr/lib64/python3.7/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver'
Any idea how to fix this? May be a different combination of Linux flavour and chrome driver from somewhere else?
This error message...
OSError: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver'
...implies that you are using an incorrect format of ChromeDriver executable.
Deep Dive
As you are using AWS EC2 ARM flavour you need to use the either ARM64 or ARM7 variant of ChromeDriver.
Additionally, you seem to have downloaded ChromeDriver v100.x where as the latest version of google-chrome is Chrome Version 99.0.4844.84
and you need the matching version of ChromeDriver as per the installed version of Google Chrome within the system.
Solution
As #Mark B pointed out in his comment you need to download the matching version of ChromeDriver as per the discussion Compile ChromeDriver on ARM
I'm trying to follow Automate the Boring Stuff and am trying to do the selenium work. I’m running Linux using Mu. Here's the code I'm trying to run
from selenium import webdriver
chromedriver = “/lorenmspeer/Downloads/chromedriver.exe”
browser = webdriver.Chrome(executable_path=chromedriver)
url = “https://www.duckduckgo.com”
browser.get(url)
I’m getting this error:
Traceback (most recent call last):
File “/home/lorenmspeer/.local/share/mu/mu_venv-38-20210401-164244/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: ‘/lorenmspeer/Downloads/chromedriver.exe’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/home/lorenmspeer/mu_code/seleniumTest22.py”, line 5, in
browser = webdriver.Chrome(executable_path=chromedriver)
File “/home/lorenmspeer/.local/share/mu/mu_venv-38-20210401-164244/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py”, line 73, in init
self.service.start()
File “/home/lorenmspeer/.local/share/mu/mu_venv-38-20210401-164244/lib/python3.8/site-packages/selenium/webdriver/common/service.py”, line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver.exe’ executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
To check where Chrome driver is installed on Linux run whereis chromedriver. Then, put this path to Chrome("your_path")
In my project it is specified in the folder I defined:
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
It should not have .exe resolution
For more info check docs:
https://chromedriver.chromium.org/getting-started
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
I found a solution. First I had to make the file executable:
chmod +x chromedriver
Then I moved it to PATH
sudo mv chromedriver /usr/local/bin/
This made the code launch the browser.
I am attempting to run the bcc tool's "profile.py", and ran into the following error:
./bcc/tools/profile.py
Sampling at 49 Hertz of all threads by user + kernel stack... Hit Ctrl-C to end.
In file included from <built-in>:1:
././include/linux/kconfig.h:5:10: fatal error: 'generated/autoconf.h' file not found
#include <generated/autoconf.h>
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
File "./bcc/tools/profile.py", line 265, in <module>
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 325, in __init__
raise Exception("Failed to compile BPF text")
The linux headers are found under the normal location of /lib/modules. This is running under kernel version 4.19.88.
Any pointer will be appreciated.
I installed python version 3.5.2, selenium version 3.0.1 and firefox version 49.0.2.
After all of that and in my shell scripting I typed
>>> from selenium import webdriver
>>> browser = webdriver.Firefox()
and got error as this below:
Could someone guide me on what is wrong here.
I appreciate it. I am just starting out on python. Thanks
#
Traceback (most recent call last):
File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
browser = webdriver.Firefox()
File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
self.service.start()
File "C:\Users\D\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
#
Every time I run a Kivy app I see OSError (see it in last line of my given example). Even though my app runs successfully. What could be the cause of this error?
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/input/providers/mtdev.py", line 197, in _thread_run
_device = Device(_fn)
File "/usr/lib/python2.7/dist-packages/kivy/lib/mtdev.py", line 131, in __init__
self._fd = os.open(filename, os.O_NONBLOCK | os.O_RDONLY)
OSError: [Errno 13] Permission denied: '/dev/input/event5'
This error is not important, it just means that kivy checked the possible input providers in your OS and found that this one is forbidden.