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
相关推荐
天天被压力12 小时前
【别再到处找免费股票数据API了:官方204个接口,32篇一次讲透 #06】Python实时行情总报错?五档盘口+逐笔一次跑通
java·人工智能·python
智能RPA12 小时前
农业与矿业行业智能体自动化平台对比评测(计量与巡检场景)
运维·人工智能·python·自动化·agent·rpa
溪语流沙12 小时前
Django + Vue电商项目第005讲:后端骨架|Django初始化、配置分层与DRF接入
vue.js·后端·python·django
代码方舟12 小时前
Python数据工程:利用天远全能消金报告优化消费金融合规体验
人工智能·python
TomEval12 小时前
【测AI】第05篇:Python 爬虫进阶 —— 动态页面爬取与 Scrapy 框架
人工智能·爬虫·python·scrapy·自动化
用户0190275816112 小时前
如何用 Python 回测 MACD 金叉死叉策略?(真实收益与频繁交易的代价)
python
huisheng_qaq12 小时前
【Python基础篇-07】深入理解python的面向对象编程
python·多态·继承·面向对象编程·封装
FanetheDivine12 小时前
学习python 2.语法速览
python
奕鼎竜瑆12 小时前
[新手小白也能学会] 01-PyTorch框架使用(上)
人工智能·pytorch·python
海天一色y12 小时前
图像分割全解析:从经典算法到深度学习的原理与实战(Python + MATLAB)
python·深度学习·算法