0

I am using Selenium and Virtualenv in Ubuntu14.04 to scrape some code on webpage. After making a virtualenv directory, while activating virtualenv using source bin/activate, I installed selenium, headless firefox, pyvirtualdisplay and firefox geckodriver.

I installed headless firefox according to here.

And I also Found out that there are different python2.7 folders at "/usr/lib/python2.7/" and "~/ladder_selenium/lib/python2.7" (ladder_selenium is the Virtualenv directory)

and after I ran a python code which contains

from selenium import webdriver

, the error below happens.

Traceback (most recent call last):
  File "predict.py", line 12, in <module>
driver = webdriver.Firefox()
  File "/home/heyjude/ladder_selenium/local/lib/python2.7/site-packages/selenium/webdriver/f
self.service.start()
  File "/home/heyjude/ladder_selenium/local/lib/python2.7/site-packages/selenium/webdriver/c
stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

Could you tell me what to fix?

EDIT for the COMMENT BELOW:

(ladder_selenium) heyjude@ladder-selenium:~$ export DISPLAY=:99
(ladder_selenium) heyjude@ladder-selenium:~$ firefox
XPCOMGlueLoad error for file /opt/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
Pramod Gharu
  • 1,105
  • 3
  • 9
  • 18
heyzude
  • 363
  • 1
  • 4
  • 20
  • Definitely has something to do with the firefox executable. Can you execute it from the command-line manually? – alecxe Dec 28 '16 at 05:27
  • do you mean by this? – heyzude Dec 28 '16 at 05:35
  • (ladder_selenium) heyjude@ladder-selenium:~$ export DISPLAY=:99 (ladder_selenium) heyjude@ladder-selenium:~$ firefox XPCOMGlueLoad error for file /opt/firefox/libmozgtk.so: libgtk-3.so.0: cannot open shared object file: No such file or directory Couldn't load XPCOM. – heyzude Dec 28 '16 at 05:36
  • what firefox version is installed? you can also manually download firefox, unpack and than try to start it using /path/to/yourfirefox/firefox-bin – metar Dec 28 '16 at 08:37
  • I used apt-get install firefox-mozilla-build. It's firefox-mozilla-build_50.1.0. Btw, what is difference between apt-get install firefox and apt-get install firefox-mozilla-build? – heyzude Dec 28 '16 at 09:58
  • I just switched to Chrome Driver, got help from https://christopher.su/2015/selenium-chromedriver-ubuntu/ – heyzude Jan 02 '17 at 14:54

0 Answers0