我正在尝试运行此脚本:
https://github.com/Chillee/coursera-dl-all
但是,脚本在第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
如何将幻影添加到我的路径中?我正在运行ubuntu 16.04并通过npm install selenium
安装selenium。
你需要下载DRIVER
之后
session = webdriver.PhantomJS("c:\driverPath")
我在命令行中用这个命令解决了同样的问题
如果/home/login/phantomjs/bin是具有可执行文件“phantomjs”的文件夹的路径,那么这是可行的。
工作溶液:
假设你是在windows上-这与linux类似
1)在这里下载phantomjs:http://phantomjs.org/download.html相应地选择windows/linux
2)解压缩phantomjs-2.1.1-windows.zip并将其保存到例如c驱动器,如c:\ phantomjs-2.1.1-windows\bin(这里有一个phantomjs.exe,它是系统所需的执行程序)
3)在Windows10上编辑环境路径以包含此bin文件夹C:\ phantomjs-2.1.1-windows\bin,如本例所示
4)您可以或不可以重新启动机器。完成!应该有用的!(Webdriver查找phantomjs.exe,现在应该已经准备好了)
相关问题 更多 >
编程相关推荐