2017-02-27 23 views
2

私は退屈なものを自動化し始めています。私はPythonでクロームWebブラウザを開こうとしています。あなたのパスを指定しPython Selenium Chrome Webdriver

Traceback (most recent call last): File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start stdout=self.log_file, stderr=self.log_file) File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in init restore_signals, start_new_session) File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Program Files (x86)/Python36-32/test.py", line 5, in browser = webdriver.Chrome() File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in init self.service.start() File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

+0

トレースバックはすでに問題を示しています:あなたのpythonコードはPATHに見つからないので 'chromedriver'を実行できません。 'chromedriver'の場所をPATHに追加するか、' chromedriver'を既にPATHにある場所に移動してください。 – fragmentedreality

答えて

7

あなたがする必要があります。

from selenium import webdriver 
from selenium.webdriver.common.by import By 
from selenium.webdriver.common.keys import Keys 

browser = webdriver.Chrome() 
browser.get('https://automatetheboringstuff.com') 

しかし、そのため、私はこのエラーを取得する:私はすでに私はこのファイルを実行しようとしたセレン及び

がインストールされていますクロムドライバはにあります。

  1. Download Chrome Drive of your desired platform from here

  2. あなたのコードが存在するディレクトリのどこにファイルを置いてもかまいません。

  3. リンクあなたのchromedriver.exe次のコードによって:

    browser = webdriver.Chrome(executable_path=r"chromedriver.exe") 
    

    か、あなたのchromedriverを格納しているこれまでのところへexecutable_pathを変更します。

  4. 完了です!これはそれを行う必要があります。

希望します。それでもまだ質問がある場合は、コメントしてください。

+0

ありがとう私はそれが働いている!助けを本当に感謝します –

+0

あなたがそれを助けたと思うならば答えを "ベストアンサー"にしてください:) –

+0

または単にエラーメッセージが何をして、あなたのシステムPATHのどこかに実行可能ファイルを置いてください –

関連する問題