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

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

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

PyInstallerは、Pythonのスクリプトを一括でWindowsなどで動く実行可能ファイルに変換できるツールです。このツールを用いることで自作のPythonプログラムを別で使用する場合でもPythonをインストールする必要がありません。

Q&A

解決済

1回答

2184閲覧

pyinstallerでexe化した際のchromedriverのパス指定方法 chromedriver-binary-auto

Anon_

総合スコア334

PyInstaller

PyInstallerは、Pythonのスクリプトを一括でWindowsなどで動く実行可能ファイルに変換できるツールです。このツールを用いることで自作のPythonプログラムを別で使用する場合でもPythonをインストールする必要がありません。

0グッド

0クリップ

投稿2021/03/26 02:29

https://qiita.com/slave/items/8ec428ce365a0699940a
上記の記事を参考にchromedriver-binary-autoをpipでインストールしました。
main.pyではimport chromedriver_binary
で読み込ませています。

pyinstaller ./main.py --onefile

でexe化しましたが、chromedriverのPATHが間違っているというエラーが出ます。
pyinstallerの--add-binaryオプションでchromedriverを含めたいのですが、
chromedriver_binaryをmoduleからimportしている場合、driverのパスはどのように指定すればよいのでしょうか。

main.py:96: DeprecationWarning: use options instead of chrome_options Exception in Tkinter callback Traceback (most recent call last): File "selenium\webdriver\common\service.py", line 72, in start File "subprocess.py", line 947, in __init__ File "subprocess.py", line 1416, in _execute_child FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "tkinter\__init__.py", line 1884, in __call__ File "main.py", line 96, in import_csvfile File "selenium\webdriver\chrome\webdriver.py", line 73, in __init__ File "selenium\webdriver\common\service.py", line 81, in start selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

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

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

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

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

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

jbpb0

2021/03/28 04:51 編集

> driverのパスはどのように指定すれば https://pypi.org/project/chromedriver-binary-auto/ の「Usage」に、「You can also get the absolute filename of the binary with chromedriver_binary.chromedriver_filename」と書かれてます import chromedriver_binary print(chromedriver_binary.chromedriver_filename) を実行したら、パスが分かりませんでしょうか? chromedriver-binary-autoを使ってないため、実際どうなのか確認できないので、外してたらごめんなさい
Anon_

2021/04/12 04:17

返信が遅くなりすみません。 仰る方法でパスは取得できたので、あとは別の環境で動くか試してみたいと思います。 本当に感謝いたします。
Anon_

2021/04/12 04:18

よければ回答のほうにご回答いただければベストアンサーとさせていただきます。
guest

回答1

0

ベストアンサー

driverのパスはどのように指定すれば

chromedriver-binary
の「Usage」に、「You can also get the absolute filename of the binary with chromedriver_binary.chromedriver_filename」と書かれてますので、

python

1import chromedriver_binary 2print(chromedriver_binary.chromedriver_filename)

を実行したら、パスが分かると思います

投稿2021/04/12 06:51

jbpb0

総合スコア7653

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.47%

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

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

質問する

関連した質問