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
相关推荐
玄同7659 分钟前
Python 系统编程双雄:sys 与 os 模块深度实践指南
开发语言·数据库·人工智能·windows·笔记·python·microsoft
Edward.W11 分钟前
Python实现文字转ASCII艺术字生成器
开发语言·python
奕成则成25 分钟前
Python 创建虚拟环境
开发语言·python
lambo mercy1 小时前
python入门
前端·数据库·python
0和1的舞者2 小时前
Python函数与列表元组全解析
python·学习·学习方法·知识
2401_841495642 小时前
【机器学习】限制性玻尔兹曼机(RBM)
人工智能·python·深度学习·神经网络·机器学习·无监督学习·限制性玻尔兹曼机
我送炭你添花2 小时前
Pelco KBD300A 模拟器:06+3.从教学级到企业级工程化转型(二次迭代)
python·测试工具·运维开发
不要em0啦2 小时前
从0开始学python:简单的练习题4
开发语言·python
小李云雾2 小时前
Python 多任务编程入门:进程的创建、同步与进程池使用
开发语言·数据库·python·oracle
AI Echoes2 小时前
LangChain中的工具与工具包
人工智能·python·langchain·prompt·agent