2016-06-19 8 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 

Pantomjを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

をダウンロードする必要があります。

では、Windows上にあるAssumming - それは、Linux

1についても同様である)、ここでphantomjsをダウンロード:http://phantomjs.org/download.htmlをそれに応じてWindows/Linuxを選択してください

2)unzipあなたのphantomjs-2.1.1-windows.zipをコピーして、例えばC:\ phantomjs-2.1.1-windows \ binのようなcドライブに保存します(ここにはあなたのシステムが必要とする実行ファイルであるphantomjs.exeがあります)

3)Windows10上でこのbinフォルダのC含めるように環境パスを編集します。この例のようなビン enter image description here

4 \ \ phantomjs-2.1.1-窓を)あなたがしたり、マシンを再起動しない場合があります。完了!それは動作するはずです!私は、コマンドラインでこのコマンドを使用して同じpromlemを解決

1

(webdriverをはphantomjs.exeを探し、それが今準備ができているはず)

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

それの仕事/ホーム/ログイン/ phantomjs/binには、パスのであれば実行可能な「phantomjs」を含むフォルダ。

関連する問題