带有 Selenium 错误的 PhantomJS:消息:'phantomjs' 可执行文件需要在 PATH 中 [英] PhantomJS with Selenium error: Message: 'phantomjs' executable needs to be in PATH

查看:34
本文介绍了带有 Selenium 错误的 PhantomJS:消息:'phantomjs' 可执行文件需要在 PATH 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行此脚本:

I am attempting to run this script:

https://github.com/Chillee/coursera-dl-all

然而,脚本在 session = webdriver.PhantomJS() 行失败并出现以下错误

However, the script fails at the line session = webdriver.PhantomJS() with the following error

Traceback (most recent call last):
  File "dl_all.py", line 236, in <module>
    session = webdriver.PhantomJS()
  File "/home/<user>/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__
    self.service.start()
  File "/home/<user>/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 69, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH. 

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f6f632864d0>> ignored

如何将 phantomjs 添加到我的 PATH 中?我正在运行 ubuntu 16.04 并通过 npm install selenium 安装了 selenium.

How do I add phantomjs to my PATH? I am running ubuntu 16.04 and installed selenium via npm install selenium.

推荐答案

我在命令行中用这个命令解决了同样的问题

I solved same promlem with this command in command line

export PATH=${PATH:+$PATH:}/home/<login>/phantomjs/bin

如果/home/login/phantomjs/bin 是具有可执行文件 'phantomjs' 的文件夹的路径就可以了.

It's work if /home/login/phantomjs/bin is the path for folder with executable 'phantomjs'.

这篇关于带有 Selenium 错误的 PhantomJS:消息:'phantomjs' 可执行文件需要在 PATH 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆