Issues getting chromedriver to work on Ubuntu AWS - python

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.

Related

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

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

Chromedriver selenium may have wrong permission on Mac [duplicate]

This question already has answers here:
'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
(22 answers)
Closed 6 months ago.
I am new at Python and selenium and I want to build an webdriver or bot respectively. I tried to execute the code below with inserting "python3 main.py" and with running the code on VS code but it is not working. The error result is enclosed. I am using Mac. The chromedriver exec is in the same main folder like the code I am writing, so actually the Path should be right. I tried different ways to solve my problem but non of them worked. I have the right chromedriver version on my mac and I even allowed my system to open the chromedriver folder.
from selenium import webdriver
browser = webdriver.Chrome('/Users/user/Desktop/it_projects/python-google-automation/src/chromedriver')
browser.get('https://www.google.com')
Error: "user#MacBook-Air-von-User python-google-automation % python3 main.py
/Users/user/Desktop/it_projects/python-google-automation/main.py:4: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(executable_path='/Users/user/Desktop/it_projects/python-google-automation/src/chromedriver')
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1845, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/Users/user/Desktop/it_projects/python-google-automation/src/chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/Desktop/it_projects/python-google-automation/main.py", line 4, in <module>
driver = webdriver.Chrome(executable_path='/Users/user/Desktop/it_projects/python-google-automation/src/chromedriver')
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 89, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 86, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://chromedriver.chromium.org/home
user#MacBook-Air-von-User python-google-automation % "
#Oxgur Sahin, you have to give executable permission to your chromedriver file /Users/user/Desktop/it_projects/python-google-automation/src/chromedriver.

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

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

Cannot install crawler for ABP

I'm getting errors when trying to install abpcrawler (Repository below).
https://github.com/adblockplus/abpcrawler
When running the command
./run.py -b /usr/bin/firefox urls.txt outputdir
I am receiving the following error:
bash-3.2# ./run.py -b /usr/bin/firefox urls.txt outputdir
Communicating with client on port 29922
['/usr/bin/firefox', '--crawler-port', '29922', '-foreground', '-profile', '/tmp/tmpgZYg1r.mozrunner']
Traceback (most recent call last):
File "./run.py", line 195, in <module>
run()
File "./run.py", line 178, in run
runner.start()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mozrunner/base/browser.py", line 67, in start
BaseRunner.start(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mozrunner/base/runner.py", line 102, in start
self.process_handler.run(self.timeout, self.output_timeout)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mozprocess/processhandler.py", line 700, in run
self.proc = self.Process([self.cmd] + self.args, **args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mozprocess/processhandler.py", line 103, in __init__
universal_newlines, startupinfo, creationflags)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Am I missing something? I have Mercurial installed and am able to clone the build tools repo.
Judging from the error message, /usr/bin/firefox couldn't be started because:
OSError: [Errno 2] No such file or directory
ABP Crawler requires Firefox to be installed, it will automate Firefox in order to collect data. If Firefox is actually installed, maybe the path is /usr/local/bin/firefox or something similar. You can run which firefox from the command line if you aren't sure.

Categories

Resources