win7安装 playwright 常见的问题
当系统为 win7 时,执行playwright install
可能会有如下提示

原因是 win7 支持 node 的最高版本为 13.14.0,但 playwright 要求 node 的版本必须高于 14,且 play 下载的 node 是版本为 16
解决方法
方法一:
1、找到自己本地 node 的安装目录:把安装目录下的 node.exe 替换 playwright 目录里面的 node.exe 文件
2、替换完成后修改D:\Programs\Python\Python37\Lib\sitepackages\playwright\driver\package\package.json 文件(playwright的安装目录)

3、然后接着修改 D:\Programs\Python\Python37\Lib\site-packages\playwright\driver\package\index.js 文件的 14 改成比 13 或 12,只要比 14 小就可以

然后接着继续执行playwright install
命令即可成功安装浏览器
方法二
如果上面的方法无法解决问题,还可以安装低版本的 playwright
playwright 的版本问题,win7 最高支持 1.15.3。因此,安装 playwright 依赖库应指定版本,不能装最新版。pip install playwright==1.15.3 下一步就能成功安装 Chromium、Firefox、WebKit 等浏览器的驱动文件(内置浏览器)python -m playwright install
方法三
既然是因为 node 版本过低,不能成功安装 playwright 的内置浏览器,那就想办法安装高版本的 node。
1、首先修改环境变量,新建一项变量名为 NODE_SKIP_PLATFORM_CHECK,变量值为 1 的系统环境变量.设置这个是跳过安装 node 时对版本的检查

2、下载 16 版本的 node 安装包:https://nodejs.org/en/

3、把下载下来的压缩文件进行解压,然后路径配置到 path 系统环境变量


4、然后保存,接着查看 node 的版本

如上图显示,说明 node16.17.0 安装成功.如果还是如下图提示版本过低,可重启你的电脑在尝试,再查看 node16.17.0 的是否安装成功,如果版本显示为 v16.17.0,则为 node 新版本安装成功.可以继续执行playwright install
进行 playwright 内置浏览器的安装,这时候就不会报版本过低的提示
- 下一篇:Monkey的使用方法和常见命令