记录成功配置anaconda后下载selenium包运行项目时遇到的问题

记录成功配置anaconda后导入selenium包运行项目时遇到的问题

1、编写py代码后导入selenium包时出现提示警告

Installing packages into 'E:\anaconda3' requires administrator privileges. Confgure a per-project virtual environment as your project interpreter to avoidnstalling packages to a protected area of the file system.

python 复制代码
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
# 导入webdriver模块
import time                                                     # 导入时间相关的库

#webdriver的路径
# driver_path = 'E:\\tools\msedgedriver.exe'
# #固定搭配直接用就行了
# service = Service(executable_path=driver_path)
#
# driver = webdriver.Edge(service=service)                      # 新建一个webdriver的实例
driver = webdriver.Edge()                      # 新建一个webdriver的实例

driver.get("https://www.baidu.com")

time.sleep(10)                                                   # 休眠2秒

2、出现这个提示是因为你在下载selenium包时,没有管理员权限。

安装包到系统目录需要管理员权限,而你可能没有这个权限。如果忽略这个警告直接继续安装的话会导致下载selenium包失败,并提示错误
EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: E:\anaconda3

3、解决方法是退出pycharm,右键pycharm快捷方式以管理员身份运行

重新导入selenium包,此时便不会提示任何警告且下载selenium包成功

相关推荐
东莞市云毅网络有限公司3 小时前
用 Node 做收录快照的周对比:差集、阈值与告警
python·sqlite·自动化运维·geo·数据监测
山楂树の4 小时前
Python Pandas 数据处理:数据读取、筛选、清洗、排序与分组
开发语言·python·pandas
Logintern094 小时前
langgraph 图编译的聊天机器人
python·langgraph
xurileidian5 小时前
第 22 篇 · 边玩边学Python · 双等号与 is 不是一回事
开发语言·python·spring
慧都产品智能化7 小时前
汽车软件年底自查:按安全影响排定缺陷整改顺序
c语言·c++·测试工具·单元测试·汽车·代码规范
钱栈up7 小时前
GitHub热榜实测|Sherlock:一个用户名搜遍全网
python·开源·github
geovindu7 小时前
python: Gradient Boosting
开发语言·后端·python·算法·boosting
Agent世界8 小时前
发布台账字段漂移:1265 条记录里 190 条没有标题
python·自动化运维
用户298698530149 小时前
Python 自动化处理 Word:按规则查找并高亮关键文本
python·api·编程语言
人工智能技术咨询.10 小时前
什么才算高质量数据集
python