在 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


alias playwright=/Library/Frameworks/Python.framework/Versions/3.10/bin/playwright
查看是否安装成功:
playwright --version
下载内核:
playwright install