记录成功配置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包成功

相关推荐
大尚来也2 分钟前
Python 调用 Ollama 本地大模型 API 完全指南
开发语言·python
少云清4 分钟前
【UI自动化测试】3_web自动化测试 _Selenium-IDE
前端·selenium·web自动化测试
qq_24218863326 分钟前
Python 春节贺卡代码
开发语言·python
Lenyiin8 分钟前
《LeetCode 顺序刷题》11 -20
java·c++·python·算法·leetcode·lenyiin
Jelena1577958579212 分钟前
淘宝图搜API接口技术深度解析:从架构设计到工程实践
python·api
瞎某某Blinder10 小时前
DFT学习记录[4] 电子和空穴的有效质量计算全流程
python·学习
chrisleequeen10 小时前
【无标题】
conda·mac·anaconda·环境变量·export·no found
Liue6123123110 小时前
基于YOLO11-C3k2-Faster-CGLU的路面落叶检测与识别系统实现
python
~央千澈~11 小时前
抖音弹幕游戏开发之第8集:pyautogui基础 - 模拟键盘操作·优雅草云桧·卓伊凡
网络·python·websocket·网络协议
占疏11 小时前
列表分成指定的份数
python