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
相关推荐
飞猪~2 小时前
LangChain python 版本 第一集
开发语言·python·langchain
2601_956319883 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_4 小时前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质4 小时前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗5 小时前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python
Metaphor6926 小时前
使用 Python 冻结 Excel 文件中的行、列和单元格
开发语言·python·excel
言乐66 小时前
Python实现建造微服务商城后台
开发语言·python·算法·微服务·架构
fenglllle6 小时前
chromadb emmbedding 向量检索
人工智能·python·embedding
cui_ruicheng6 小时前
Python从入门到实战(六):非序列容器
开发语言·python
百里香酚兰7 小时前
【python学习笔记】pyttsx3库疑似只播报一次语音
笔记·python·学习