Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble connecting to phantomJs webdriver using python and selenium

I am trying to run a python script on a linux server which uses selenium and a phantomjs webdriver; however, I keep getting the following error message:

selenium.common.exceptions.WebDriverException: Message: Service /home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs unexpectedly exited. Status code was: 127

Here is a simple test script that fails and generates this error:

import selenium
from selenium import webdriver

driver = webdriver.PhantomJS(executable_path='/home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs')

calling file on the path, returns:

file  /home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
/home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=d0f2a21ff9e0b82113a2095e7cbca7dceaba88fb, stripped

Does anyone have any idea how I can get this script up and running? I've read over what appear to be similar stackoverflow questions and attempted to apply suggested solutions such as reinstalling phantom via npm and executing the script with sudo, but have had no luck. If I can provide anymore info please let me know.

like image 301
nick Avatar asked Jul 12 '16 20:07

nick


People also ask

Does Selenium support PhantomJS?

Selenium considers PhantomJS as deprecated, so you need to us either Chrome or Firefox in headless mode.

How do I use PhantomJS in Python?

To use the PhantomJS webdriver, all you need to do is change it to PhantomJS(). Then will This will work with both Python 2.7 and Python 3. On Windows, the path should be changed to the location of your phantomjs installation.

Is PhantomJS faster than Selenium?

Key Differences Between Selenium and PhantomJS Being a headless browser, the interactions are much faster than the real browser. So the performance time is smoother in PhantomJS than in Selenium.


1 Answers

sudo apt-get install libfontconfig

This solved my issue.

like image 99
nick Avatar answered Nov 15 '22 08:11

nick