twil python linux errors - python

I've a raspberry PI whit raspbian. When i try to start a python application whit selenium it give me some errors.
This is the application:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
browser = webdriver.Firefox(executable_path=r'/home/pi/Desktop/geckodriver')
This is errors:
Traceback (most recent call last):
File "uno.py", line 5, in <module>
browser = webdriver.Firefox(executable_path=r'/home/pi/Desktop/geckodriver')
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 160, in __init__
self.service.start()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
How can i fix?

An exec error indicates you took the wrong OS file for geckodriver. See the below for all release
https://github.com/mozilla/geckodriver/releases
As of today (27th Jun 2018), you should probably be picking below
https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-arm7hf.tar.gz
Also make sure to do
chmod +x /home/pi/Desktop/geckodriver
So that it has executable rights

Related

Permission error [winerror 5] access is denied-Selenium chrome webdriver

I'm following a tutorial on using selenium and I'm having trouble getting started. Namely, when I try to run the code below, I get the error below. I have seen other users with the same problem, I have tried their solutions, they did not work.
These solutions include:
running pycharm as administrator,
setting permissions for all
group/usernames of subprocess.py and service.py
site-package(and pretty much every file/folder within) to full
access.
from selenium import webdriver
driver = webdriver.Chrome(r"C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\selenium\webdriver\chrome")
driver.get("http://python.org")
Here is the full error message:
Traceback (most recent call last): File
"C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py",
line 76, in start
stdin=PIPE) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py",
line 775, in init
restore_signals, start_new_session) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py",
line 1178, 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/User/PycharmProjects/PythonProject/DataCollection", line 2,
in
driver = webdriver.Chrome(r"C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\selenium\webdriver\chrome")
File
"C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py",
line 73, in init
self.service.start() File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\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: 'chrome'
executable may have wrong permissions. Please see
https://sites.google.com/a/chromium.org/chromedriver/home
first, replace all \ with /
and then add the executable filename in the file location:
driver = webdriver.Chrome(r'C:/Users/User/AppData/Local/Programs/Python/Python37-32/Lib/site-packages/selenium/webdriver/chrome/chromedriver.exe')

Firefox won't open using geckodriver

I'm running my scripts through Cygwin and everything was working just fine until I had to reinstall it. Now my script freezes as soon as I try to open the browser, not giving any error. I'm using geckodriver v0.25.0 and firefox 66.0.4. Everything is the same as before as far as I know.
Traceback (most recent call last):
File "t.txt", line 5, in <module>
driver = webdriver.Firefox(executable_path="./geckodriver.exe")
File "/usr/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/usr/lib/python3.7/site-packages/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 1476, in _execute_child
part = os.read(errpipe_read, 50000)
KeyboardInterrupt
Code used
#!/usr/bin/env python
from selenium import webdriver
driver = webdriver.Firefox(executable_path="./geckodriver.exe")
driver.get("https://inventwithpython.com")

error while exeutiing Selenium Python automation script

I just copied selenium script from web and trying to learn selenium python automation.
Here is the script
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.facebook.com")
While running I got following error
Traceback (most recent call last):
File "C:\Users\hpatel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\hpatel\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\Users\hpatel\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1155, 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\hpatel\python\PythonLearn\src\Example1.py", line 8, in <module>
driver = webdriver.Firefox()
File "C:\Users\hpatel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 160, in __init__
self.service.start()
File "C:\Users\hpatel\AppData\Local\Programs\Python\Python37-32\lib\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: 'geckodriver' executable needs to be in PATH.
What is the issue?
I copied geckodriver file to c drive and define the path too.
Just replace this line :
driver = webdriver.Firefox()
To:
driver = webdriver.Firefox(executable_path = r'C:/Users/user***/Downloads/geckodriver-v0.20.1-win64/geckodriver.exe')

Python dryscrape "Xvfb does not start" under XQuartz & xvfbwrapper & MacOSX Sierra

Under MacOSX Sierra, and XQuartz 2.7.11, Python 2.7. I was able to install dryscrape and its required other python packages. I've tried quite a few methods to get some simple code working, but I can't seem to get it working. Here is the simple code:
#!/usr/bin/python
#coding: utf-8
import dryscrape
testurl = 'http://avi.im/stuff/js-or-no-js.html'
dryscrape.start_xvfb()
session = dryscrape.Session()
session.visit(testurl)
exit()
You can see it is a simple python script file. It fails on either the start_svfb() or the Session() line. I can post the errors and such, but can I start a discussion on simply what check list should I setup, run, and test to make sure the X11 environment is right? Do I run the script under OS X terminal or XQuartz? What am I missing? etc.?
Thanks in advance, Lucas.
here is the last traceback from python:
Traceback (most recent call last):
File "./fred.py", line 19, in
session = dryscrape.Session()
File "build/bdist.macosx-10.12-intel/egg/dryscrape/session.py", line 22, in __init__
File "build/bdist.macosx-10.12-intel/egg/dryscrape/driver/webkit.py", line 30, in __init__
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 230, in __init__
self.conn = connection or ServerConnection()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 507, in __init__
self._sock = (server or get_default_server()).connect()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 450, in get_default_server
_default_server = Server()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 416, in __init__
stderr = subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Trouble setting up selenium with python3(linux)

Im somewhat a beginner with Python and recently stumbled across the Selenium module, would appreciate it if someone could help me?
I cant seem to get the selenium module working at all with python3.
I have downloaded the geckodriver for firefox but still no luck, or am installing it incorrectly maybe?
Im using this code:
from selenium import webdriver
browser = webdriver.Firefox()
And seem to be receiving this error:
'OSError: [Errno 8] Exec format error'
A copy of the whole error message is pasted below.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/chron/.local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
self.service.start()
File "/home/chron/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
OSError: [Errno 8] Exec format error
this looks like it is failing to start geckodriver because you are using a binary that is compiled for the wrong architecture. Make sure you download the correct version for your architecture from https://github.com/mozilla/geckodriver/releases
for example, if you are running 64-bit linux (amd64), you need to download the geckodriver tarball that ends with "linux64.tar.gz".

Categories