我试图在一个使用selenium和一个phantomjs webdriver的Linux服务器上运行一个python脚本; 但是,我不断收到以下错误信息:
selenium.common.exceptions.WebDriverException: Message: Service /home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs unexpectedly exited. Status code was: 127
这是一个简单的testing脚本,失败并产生这个错误:
import selenium from selenium import webdriver driver = webdriver.PhantomJS(executable_path='/home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs')
调用path上的文件,返回:
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问题,并试图应用build议的解决scheme,如通过npm重新安装幻像和执行脚本与sudo,但没有运气。 如果我可以提供任何信息,请让我知道。
sudo apt-get install libfontconfig
这解决了我的问题。