Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS unexpectedly exits on Selenium : WebDriverException with status code 127

I am using a global PhantomJS on my Mac OS X for multiple Javascript and Python selenium projects. For the first time, I set up a virtual environnement using virtualenv :

virtualenv Python3.5 Path/To/MyEnvironnement

Then :

Path/To/MyEnvironnement
. bin/activate
which phantomjs

... returns my global selenium : /Users/Me/.npm-packages/bin/phantomjs

But every time I call :

driver = webdriver.PhantomJS(executable_path=r'/Users/Me/.npm-packages/bin/phantomjs')

I get this error :

Traceback (most recent call last):
File "/Path/To/MyEnvironnement/script/spider/crawl/Urls.py", line 194, in <module>
init_driver()
File "/Path/To/MyEnvironnement/script/spider/crawl/Urls.py", line 29, in init_driver
driver = webdriver.PhantomJS(executable_path=r'/Users/Me/.npm-packages/bin/phantomjs')
File "/Path/To/MyEnvironnement/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
self.service.start()
File "/Path/To/MyEnvironnement/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 86, in start
self.assert_process_still_running()
File "/Path/To/MyEnvironnement/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 99, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /Users/Me/.npm-packages/bin/phantomjs unexpectedly exited. Status code was: 127

It's been 24 hours since I first got this issue, and I read virtually all posts that could refer to it.

I tried, without success, to create a nodeenv inside my virtualenv : running phantomjs inside python virtualenv for selenium project

like image 729
user6403833 Avatar asked Oct 18 '16 09:10

user6403833


1 Answers

I guess its too late, but for future reference I've solved this issue by:

sudo apt-get install libfontconfig

The answer was found here:

Trouble connecting to phantomJs webdriver using python and selenium

like image 179
Alex Zamai Avatar answered Oct 21 '22 06:10

Alex Zamai