PhantomJS with Selenium错误:消息:“PhantomJS”可执行文件需要在路径中
回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在尝试运行此脚本:</p>
<p><a href="https://github.com/Chillee/coursera-dl-all" rel="noreferrer">https://github.com/Chillee/coursera-dl-all</a></p>
<p>但是,脚本在第<code>session = webdriver.PhantomJS()</code>行失败,并出现以下错误</p>
<pre><code>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
</code></pre>
<p>如何将幻影添加到我的路径中?我正在运行ubuntu 16.04并通过<code>npm install selenium</code>安装selenium。</p>