2016-06-19 74 views
11

我試圖運行此腳本:PhantomJS硒錯誤:消息:「phantomjs」可執行文件需要在PATH

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/shaan/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__ 
    self.service.start() 
    File "/home/shaan/.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安裝硒。

+0

是否安裝了phantomjs? –

+0

應該是。有什麼方法我可以仔細檢查? – quantumbutterfly

+1

做'哪個phantomjs'。如果不在那裏,只需將其移動到/ usr/bin或PATH中的任何其他位置 – pguardiario

回答

9

你需要的session = webdriver.PhantomJS("c:\driverPath")

6

工作液後下載DRIVER

Assumming你是在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 \斌如本例中 enter image description here

4),你可能會或可能無法重新啓動您的計算機。完成!它應該工作! (webdriver的查找phantomjs.exe,它現在應該準備好)

1

我在命令行解決同promlem用這個命令

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

這是工作,如果/家庭/登錄/ phantomjs/bin目錄的路徑文件夾與可執行'phantomjs'。

相關問題