PhantomJS unexpectedly exits on Selenium : WebDriverException with status code 127

匿名 (未验证) 提交于 2019-12-03 02:20:02

问题:

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

回答1:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!