質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

3355閲覧

macでchromedriverが開きません

ume1010

総合スコア4

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/11/20 10:49

編集2020/11/20 10:55

homebrewからchromedriverをインストールし、下のようにコードを書いたのですが、browser = webdriver.Chrome() のところでエラーが出てしまいました。考えらる原因はなんでしょうか?よろしくお願いします。

!pip install selenium

!pip install beautifulsoup4

from selenium import webdriver

import time
import pandas as bd

USER = "test_user"
PASS = "test_pw"

browser = webdriver.Chrome()
browser.implicitly_wait(5)**
#エラー箇所

WebDriverException Traceback (most recent call last)
<ipython-input-5-a95e7033a7bf> in <module>
----> 1 browser = webdriver.Chrome()
2 browser.implicitly_wait(5)

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py in init(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
74
75 try:
---> 76 RemoteWebDriver.init(
77 self,
78 command_executor=ChromeRemoteConnection(

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py in init(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
155 warnings.warn("Please use FirefoxOptions to set browser profile",
156 DeprecationWarning, stacklevel=2)
--> 157 self.start_session(capabilities, browser_profile)
158 self._switch_to = SwitchTo(self)
159 self._mobile = Mobile(self)

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
250 parameters = {"capabilities": w3c_caps,
251 "desiredCapabilities": capabilities}
--> 252 response = self.execute(Command.NEW_SESSION, parameters)
253 if 'sessionId' not in response:
254 response = response['value']

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
240 alert_text = value['alert'].get('text')
241 raise exception_class(message, screen, stacktrace, alert_text)
--> 242 raise exception_class(message, screen, stacktrace)
243
244 def _value_or_default(self, obj, key, default):

WebDriverException: Message: unknown error: cannot find Chrome binary

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

otn

2020/11/20 11:47

> cannot find Chrome binary Chromeが見つからないと言ってますが、Chromeはどうやってインストールしましたか?
ume1010

2020/11/24 07:01

google chromeのダウンロードページからインストールしました。
guest

回答1

0

ベストアンサー

Chromeが存在しないかデフォルトパスに無いため、chromedirverから見つからない可能性があります。

まずはファインダーでアプリケーション配下にGoogle Chrome.appが存在するか確認ください。
ターミナルで'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'と'の囲み付きで打ち込んで、Chromeが起動するか確認ください。

上記がうまくいかなければ、Google Chrome.appを探して正しいパスをみつけてください。
(Contents以降のパスはファインダーでは見えません)

正しいパスがわかったら、可能であればファインダー上でデフォルトパスに移動させましょう。
もしそのまま使うとしたら、下記のコードでbinary_locationを正しいパスに修正する必要があります。

Python

1options = webdriver.chrome.options.Options() 2options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' 3browser = webdriver.Chrome(options=options)

投稿2020/11/21 11:37

編集2020/11/24 12:15
toast-uz

総合スコア3266

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

otn

2020/11/24 09:35 編集

> chromedriverがパスに無いです。 違います。chromedriverは起動できて、chromeを起動できないというエラーです。 このケースは初めて見ました。
toast-uz

2020/11/24 09:48

そういうことですか!成り行きを見守って、結果が出たら注記させていだたきます
toast-uz

2020/11/24 12:13

質問者様の反応が無いので、いったん、Chromeが見つからない前提での回答に変更しました。
ume1010

2020/11/25 06:46

以下のパスにありました。 /Applications/Google\ Chrome\ 2.app/Contents/MacOS/Google\ Chrome
toast-uz

2020/11/25 09:15 編集

ファインダーのアプリケーションフォルダでGoogle Chrome 2.appをGoogle Chrome.appにすれば、動くと思います。回答の「可能であれば」の指針です。なお.appが表示されていなければ、.app無しで上記変更してください。
ume1010

2020/11/27 07:03

変更できなかったため、chromeを削除し、再度インストールしました。すると問題を解決するに至りました。親身に回答していただきありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問