Exec format error - while executing sample code from selenium [duplicate] - python

from selenium import webdriver
browser = webdriver.Firefox(executable_path="/usr/bin/geckodriver")
browser.get('http://www.ubuntu.com/')
The entire stack trace looks like:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 160, in __init__
self.service.start()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'geckodriver'
my path to geckodriver is:
/usr/bin/geckodriver
And selenium is in:
selenium in /usr/local/lib/python3.6/dist-packages (3.12.0)
Thanks in advance!

You have most probably installed a version of geckodriver that is meant for a different OS/platform! get the correct version from https://github.com/mozilla/geckodriver/releases and replace the one you have.

Use this command to install the latest chrome driver which supports selenium:
sudo apt-get install chromium-chromedriver

Related

Selenium Library dont work correctly (Python 3)

After a long break of programming I wanted to start again with selenium.
I have installed the newest version and I placed the geckodriver executable in PATH, but theres a error.
Traceback (most recent call last):
File "/home/pi/Desktop/test.py", line 3, in <module>
browser = webdriver.Firefox()
File "/home/pi/Desktop/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/home/pi/Desktop/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'geckodriver
And my script is:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
I searched very long now but dont found anything. I hope some1 can help me.
Max
EDIT: I fixed it on my own by using sudo apt-get install chromium-chromedriver
Thanks for the guy in te comments for help

Issues getting chromedriver to work on Ubuntu AWS

I'm having problems getting chromedriver to run on an AWS EC2 instance, using Ubuntu. As you can see from the image below, I've used FileZilla to drop chromedriver into my remote Ubuntu site, in the same folder as the Python script itself. I've then modified my python code to access the chromedriver from Ubuntu server, rather from my local path:
options = Options()
driverLocation = webdriver.Chrome(chrome_options=options,
executable_path=r'/home/ubuntu/bandsintown/chromedriver 4')
driverLocation.quit()
However, I'm getting the following error:
Traceback (most recent call last):
File "BandsInTown_Scraper_SF.py", line 33, in <module>
driverLocation = webdriver.Chrome(chrome_options=options, executable_path=r'/home/ubuntu/bandsintown/chromedriver 4')
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/ubuntu/bandsintown/chromedriver 4'
Image:
Try chromedriver\ 4 or remove the space from the filename.

I am getting an error in using Selenium in python [duplicate]

This question already has answers here:
Error message: "'chromedriver' executable needs to be available in the path"
(33 answers)
Closed 5 years ago.
I tried using selenium for building a program but it just does not support web driver. I am getting the following error.
Traceback (most recent call last):
File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, 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 "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\records\sel.py", line 2, in <module>
browser = webdriver.Chrome()
File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, 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
Help would be appreciated.
it seems that you need to install chrome and chromedriver.
for debian linux:
apt install chromium
wget https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo cp chromedriver /usr/bin/

Python Selenium " 'geckodriver' executable needs to be in PATH"

Even though I have already put geckodriver in there and I restarted my computer, it still prints the same thing.
>>>from selenium import webdriver
>>>browser = webdriver.Firefox()
Traceback (most recent call last):
File "D:\Python\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "D:\Python\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "D:\Python\lib\subprocess.py", line 992, 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 "<stdin>", line 1, in <module>
File "D:\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in __init__
self.service.start()
File "D:\Python\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
And an error before that as well! Someone please help a newbie out. Image of the Path variable
You need to mention the path of the gecko driver executable. Below line will get you some idea.
driver=webdriver.Firefox(executable_path="add geckodriver.exe")
Hope this helps. Thanks.

selenium: unable to access geckodriver

I dowloaded the latest versions of both selenium and geckodriver.
I did the following:
bash
cp Downloads/geckodriver /usr/local/bin/
PATH=$PATH:/usr/local/bin/geckodriver
python
from selenium import webdriver
browser = webdriver.Firefox()
error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chris/anaconda/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
self.service.start()
File "/Users/chris/anaconda/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/Users/chris/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Users/chris/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
UPDATE
I did the same thing with chrome web driver:
browser = webdriver.Chrome()
error
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.3 x86_64)
Is this something to do with specifying the path?? Really confused as I am inexperienced with bash

Categories

Resources