qua*_*fly 19 python selenium phantomjs selenium-webdriver
我正在尝试运行此脚本:
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
Run Code Online (Sandbox Code Playgroud)
如何将phantomj添加到PATH中?我正在运行ubuntu 16.04并通过安装selenium npm install selenium.
Leo*_*kan 16
你需要下载DRIVER
之后 session = webdriver.PhantomJS("c:\driverPath")
Dun*_*ung 13
工作方案:
假设你在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,现在应该准备好了)
小智 5
我在命令行中使用此命令解决了同样的问题
export PATH=${PATH:+$PATH:}/home/<login>/phantomjs/bin
Run Code Online (Sandbox Code Playgroud)
如果/ home / login / phantomjs / bin是带有可执行文件'phantomjs'的文件夹的路径,则可以使用。
| 归档时间: |
|
| 查看次数: |
38187 次 |
| 最近记录: |