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

相关推荐
多恩Stone7 小时前
【3DV 进阶-2】Hunyuan3D2.1 训练代码详细理解下-数据读取流程
人工智能·python·算法·3d·aigc
xiaopengbc7 小时前
在 Python 中实现观察者模式的具体步骤是什么?
开发语言·python·观察者模式
别来无恙1498 小时前
使用Python和Selenium进行Web自动化测试:从入门到实践
selenium·测试工具
Python大数据分析@8 小时前
python用selenium怎么规避检测?
开发语言·python·selenium·网络爬虫
ThreeAu.8 小时前
Miniconda3搭建Selenium的python虚拟环境全攻略
开发语言·python·selenium·minicoda·python环境配置
偷心伊普西隆8 小时前
Python EXCEL 理论探究:格式转换时处理缺失值方法
python·excel
精灵vector9 小时前
LLMCompiler:基于LangGraph的并行化Agent架构高效实现
人工智能·python·langchain
java1234_小锋9 小时前
Scikit-learn Python机器学习 - 特征降维 压缩数据 - 特征选择 - 移除低方差特征(VarianceThreshold)
python·机器学习·scikit-learn