小编nic*_*ick的帖子

无法使用python和selenium连接到phantomJs webdriver

我试图在使用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
Run Code Online (Sandbox Code Playgroud)

这是一个失败的简单测试脚本并生成此错误:

import selenium
from selenium import webdriver

driver = webdriver.PhantomJS(executable_path='/home/ubuntu/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs')
Run Code Online (Sandbox Code Playgroud)

在路径上调用文件,返回:

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
Run Code Online (Sandbox Code Playgroud)

有谁知道如何让这个脚本运行起来?我已经阅读了类似的stackoverflow问题并试图应用建议的解决方案,例如通过npm重新安装幻像并使用sudo执行脚本,但没有运气.如果我可以提供更多信息,请告诉我.

python linux selenium phantomjs

5
推荐指数
1
解决办法
5726
查看次数

标签 统计

linux ×1

phantomjs ×1

python ×1

selenium ×1