Failed to run Selenium + Python Script on linux mint with Chrome and Firefox

I cannot run / execute python (3.5) + selenium (3.4.0) script on Linux Mint 18.1 Serena using Chrome and Firefox .

More details:

When I try to run below script for Chrome or Firefox browser I run into problems, it works fine on Windows machine, but gives some weird problems on Linux Mint.

Chrome: -

import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.google.com/xhtml');
driver.close()

      

Result: -

Traceback (most recent call last):
File "sample1.py", line 6, in <module>
driver.get('http://www.google.com/xhtml');
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg /selenium/webdriver/remote/webdriver.py", line 261, in get
self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/remote/webdriver.py", line 247, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/remote/remote_connection.py", line 464, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/remote/remote_connection.py", line 488, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

      

FireFox: -

import time
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.google.com/xhtml');
driver.close()

      

Result: -

Traceback (most recent call last):
File "sample1.py", line 4, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/firefox/webdriver.py", line 142, in __init__
self.service.start()
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/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

      

+3


source to share


3 answers


I resolved the problem by changing the geckodriver permissions and moving the geckodriver to / usr / local / bin

chmod +x geckodriver
cp geckodriver /usr/local/bin/

      



I think it will work the same as for chrome Thanks everyone for helping guys

+3


source


Ok, so looking around it seems like this is a complaint about binaries you are using, at least for geckodriver. As seen here OSError: [Errno 8] Exec format secenium format error

You should check the geckodriver / chromedrive for which you set the paths and make sure the binaries you are using are not for the Windows version (which, in my opinion, is the reason it works for Windows and not linux mint - assuming what do you share the car)



I hope this helps. :) (I have to admit that, I'm not entirely sure why the errors are completely different for both browsers)

0


source


The problem might be in Pycharm. This works fine if I run from terminal. There might be a permission issue from Pycharm.

0


source







All Articles