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
相关推荐
会博通·代码搬运工5 分钟前
会博通API对接实战:工程企业文档分布式采集系统的技术实现与Python SDK详解
开发语言·分布式·python·线性代数·矩阵·架构·电子档案合规
空堂与归12 分钟前
大模型再火,也得先过 class 这一关
python
Muselit13 分钟前
Python 泛型:把 list[User] 讲明白
python·fastapi
2501_9160074719 分钟前
Python实现HTTPS爬虫的完整指南:使用requests、BeautifulSoup、Selenium和Scrapy
爬虫·python·ios·小程序·https·uni-app·iphone
gptAI_plus26 分钟前
别把整个仓库塞给 AI:用 Python 生成安全的代码上下文清单
python·chatgpt
吃饱了得干活27 分钟前
Agent 记忆系统:从短期记忆到长期记忆
python·langchain·agent
大鱼>44 分钟前
DSPy:LLM程序自动编译与提示词优化
开发语言·人工智能·python·深度学习
2401_843253701 小时前
金融智能:AI如何重构银行业未来
人工智能·python·金融
uncle_ll1 小时前
服务器选型、微调范式、训练优化与环境搭建
服务器·python·gpt·llm·nlp
久久学姐1 小时前
Python开发爬虫的常用技术架构
爬虫·python·http·框架·数据存储