Selenium Library dont work correctly (Python 3) - python

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

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

unable to run basic Py program in Pycharm with Selenium

I'm very new to coding. Trying to run the below basic lines from past 20 days, and getting the below error. Kindly help. Tried installing uninstalling python, selenium & pycharm. still same issue :(
My code:
from selenium import webdriver
browser = webdriver.Chrome(executable_path = 'C:\Program Files (x86)\Google\Chrome\Application')
browser.get('https://www.google.com')
browser.quit()
Error -
"C:\Python 3.7.6\python.exe" C:/Users/PycharmProjects/sel/sel1.py
Traceback (most recent call last):
File "C:\Python 3.7.6\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Python 3.7.6\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Python 3.7.6\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/PycharmProjects/sel/sel1.py", line 2, in <module>
browser = webdriver.Chrome(executable_path = 'C:\Program Files (x86)\Google\Chrome\Application')
File "C:\Python 3.7.6\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Python 3.7.6\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Application' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1
Thanks in advance.
Your executable path is deeply problematic. The error being thrown show that your programs access to the chrome driver is being blocked. Change the position of the chrome driver to somewhere else(desktop, user directory etc) and change the executable path in your code to the new path where you put your chromedriver and you should be okay

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.

Categories

Resources