4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Playwright for PythonをWindows10で動かす

Posted at

#環境
Windows 10
Python3.9

インストール

とりあえずPlaywrightをpipでインストール

pip install playwright

一回Playwrightを実行

playwright codegen https://ja.wikipedia.org/

こんな感じでエラーになる。

(node:20312) UnhandledPromiseRejectionWarning: browserType.launch: Failed to launch chromium because executable doesn't exist at C:\Users\<username>\AppData\Local\ms-
playwright\chromium-854489\chrome-win\chrome.exe
Try re-installing playwright with "npm install playwright"Error

npmでplaywrightをインストールしろとか言われてるので、ここからNodejsのインストーラーをダウンロードしてインストールしてnpmでplaywrightをインストール。
ちなみにnodeのバージョンはv14.16.0。

npm install playwright

もう一回Playwrightを実行

playwright codegen https://ja.wikipedia.org/

やっぱり同じエラーが出る・・・

(node:20312) UnhandledPromiseRejectionWarning: browserType.launch: Failed to launch chromium because executable doesn't exist at C:\Users\<username>\AppData\Local\ms-
playwright\chromium-854489\chrome-win\chrome.exe
Try re-installing playwright with "npm install playwright"Error

C:\Users\<username>\AppData\Local\ms-playwright\chromium-851527以下にchrome.exeがインストールされてた。どうもchromium-851527の部分が合わないらしい・・・
仕方ないので、chromium-851527をコピッて複製して、ディレクトリ名をエラーが出ていたchromium-854489に変更。

で、Playwrightを実行

playwright codegen https://ja.wikipedia.org/

今度は動作した。

ひょっとしたらc++のコンパイラとか必要かもしれないけど、自分は別件でインストールしてたから問題なかったけど、なんか言われたらVisualStudioをインストールする。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?