在 mac 上 pip install playwright 或者 pip install pytest-playwright
尝试运行时出现以下错误下图错误:
zsh: command not found: playwright
解决办法:用下面命令重新安装即可。
方法一:重装
pip uninstall pytest-playwright
pip install pytest-playwright
方法二:配置环境变量:
1、使用pip查找playwright位置
pip show playwright
2、pip返回playwright基础信息
Name: playwright
Version: 1.41.2
Summary: A high-level API to automate web browsers
Home-page: https://github.com/Microsoft/playwright-python
Author: Microsoft Corporation
Author-email:
License: Apache-2.0
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: greenlet, pyee
Required-by: pytest-playwright
3、修改配置信息:
vim ~/zshrc
export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.10/bin/playwright"
source ~/.zshrc
方法三:使用快捷命令
(前两个方法是网上其他两个大佬提供的,我没成功,这个是我自己趟的坑,其实是我安装的时候没有看提示)
修改配置
vim ~/zshrc
![image.png](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5bf239958c4149f1bb25db30b20e8183~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=2842&h=1034&s=1229062&e=png&b=010802)
![image.png](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/462e0a4549b64e0bbac7ae0cd379f1ee~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=426&h=108&s=22319&e=png&b=040301)
alias playwright=/Library/Frameworks/Python.framework/Versions/3.10/bin/playwright
查看是否安装成功:
playwright --version
下载内核:
playwright install