2016-07-12 42 views
5

我想在使用selenium和phantomjs webdriver的linux服務器上運行python腳本;不過,我不斷收到以下錯誤信息:使用python和selen連接到phantomJs webdriver的問題

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

下面是一個簡單的測試腳本失敗,並生成該錯誤:

import selenium 
from selenium import webdriver 

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

調用路徑下的文件,返回:

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 

有沒有人有任何想法如何讓這個腳本啓動和運行?我已經閱讀了似乎是類似的stackoverflow問題,並試圖應用建議的解決方案,如通過npm重新安裝幻像和用sudo執行腳本,但沒有運氣。如果我可以提供更多信息,請告訴我。

回答

20
sudo apt-get install libfontconfig 

這解決了我的問題。

相關問題