pip install selenium异常

error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try brew install xyz, where xyz is the package you are trying to install. If you wish to install a Python library that isn't in Homebrew, use a virtual environment: python3 -m venv path/to/venv source path/to/venv/bin/activate python3 -m pip install xyz If you wish to install a Python application that isn't in Homebrew, it may be easiest to use 'pipx install xyz', which will manage a virtual environment for you. You can install pipx with brew install pipx You may restore the old behavior of pip by passing the '--break-system-packages' flag to pip, or by adding 'break-system-packages = true' to your pip.conf file. The latter will permanently disable this error. If you disable this error, we STRONGLY recommend that you additionally pass the '--user' flag to pip, or set 'user = true' in your pip.conf file. Failure to do this can result in a broken Homebrew installation. Read more about this behavior here: <https://peps.python.org/pep-0668/\> note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. [notice] A new release of pip is available: 24.0 -> 24.1.2 [notice] To update, run: python3.12 -m pip install --upgrade pip

复制代码
创建和使用虚拟环境
虚拟环境是一个独立于系统Python环境的空间,可以在其中安装和管理Python包。按照以下步骤创建和使用虚拟环境:

创建虚拟环境:

bash
复制代码
python3 -m venv myenv
这将在当前目录下创建一个名为myenv的虚拟环境。

激活虚拟环境:

在 Linux 或 MacOS 上:

bash
复制代码
source myenv/bin/activate
在 Windows 上:

bash
复制代码
myenv\Scripts\activate
当虚拟环境激活后,终端提示符会显示为(myenv),表示你现在在虚拟环境中工作。

在虚拟环境中安装Selenium:

确保在虚拟环境中后,使用普通的pip命令来安装Selenium:

bash
复制代码
pip install selenium
相关推荐
ValhallaCoder1 小时前
hot100-栈
数据结构·python·算法·
MediaTea5 小时前
Python:生成器表达式详解
开发语言·python
-To be number.wan5 小时前
Python数据分析:SciPy科学计算
python·学习·数据分析
Dxy12393102165 小时前
DataFrame数据修改:从基础操作到高效实践的完整指南
python·dataframe
overmind7 小时前
oeasy Python 115 列表弹栈用pop删除指定索引
开发语言·python
hnxaoli8 小时前
win10程序(十六)通达信参数清洗器
开发语言·python·小程序·股票·炒股
电饭叔8 小时前
文本为 “ok”、前景色为白色、背景色为红色,且点击后触发 processOK 回调函数的 tkinter 按钮
开发语言·python
雷电法拉珑9 小时前
财务数据批量采集
linux·前端·python
shangjian00710 小时前
Python基础-With关键字
python
zchxzl11 小时前
亲测2026京津冀可靠广告展会
大数据·人工智能·python