我正在尝试运行此脚本:
https://github.com/Chillee/coursera-dl- all
但是,脚本在此行失败,session = webdriver.PhantomJS()并显示以下错误
session = webdriver.PhantomJS()
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并通过安装seleniumnpm install selenium。
npm install selenium
我在命令行中使用此命令解决了同样的问题
export PATH=${PATH:+$PATH:}/home/<login>/phantomjs/bin
如果/ home / login / phantomjs / bin是带有可执行文件’phantomjs’的文件夹的路径,则可以使用。