3

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

Details:

When I try to run below script for Chrome or Firefox browser I am facing issues, It runs perfectly fine on windows machine but giving some weird issues 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
Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
tmnj7
  • 103
  • 9
  • Have you got geckodriver and/or chrome driver installed? – Generic Snake Apr 27 '17 at 18:29
  • Yes @GenericSnake geckodriver and chromedriver both installed and added to system PATH – tmnj7 Apr 27 '17 at 18:36
  • Are you using the latest versions of chrome/firefox? I know firefox updated recently, so that may be affecting it: see http://stackoverflow.com/questions/43665289/unable-to-run-selenium-python-script-on-linux-mint-with-chrome-and-firefox?noredirect=1#comment74378071_43665289 Although it seems you have two different errors which is confusing... – Generic Snake Apr 27 '17 at 18:43
  • Yes @GenericSnake Firefox and Chrome both updated, I tried on older version of Firefox but I am observing same issues – tmnj7 Apr 27 '17 at 18:48

3 Answers3

3

I resolved issue by changing permissions of geckodriver and move geckodriver under /usr/local/bin

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

I think so it will work same for chromedriver Thanks for all help guys

tmnj7
  • 103
  • 9
0

Ok, so having a look around, it seems that this a complaint about the binaries you're using for at least geckodriver. As seen here OSError: [Errno 8] Exec format error selenium

You should check the geckodriver/chromedrive you set the paths for, and make sure that the binaries you're using aren't for the windows version (which i suspect is the reason why it works for windows and not for linux mint - assuming you're sharing the machine)

I'm hoping that helps you. :) (I must admit though, I'm not quite sure why the errors are totally different for both browsers)

Community
  • 1
  • 1
Generic Snake
  • 575
  • 1
  • 5
  • 13
0

The issue could be Pycharm. It works fine if I run from terminal. Could be a permission issue from Pycharm.

TheProgramMAN123
  • 487
  • 1
  • 5
  • 13