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

相关推荐
zmzb0103几秒前
Python课后习题训练记录Day123
开发语言·python
PersistJiao2 分钟前
python环境下免费、专业的中英翻译
开发语言·windows·python·机器翻译
hujinyuan2016017 分钟前
中国电子学会青少年软件编程(Python)(二级)等级考试试卷-真题+答案(2026年3月)
python·机器人
老毛肚20 分钟前
记一次逆向
开发语言·python
星恒随风34 分钟前
Python 基础语法详解(3):顺序语句、条件语句和循环语句一篇讲清楚
开发语言·笔记·python·学习
凤头百灵鸟35 分钟前
Python语法进阶篇 --- re库、os库、sys库、time库、logging库、random库
python
276695829242 分钟前
jd 变速滑块逆向角度分析
前端·python·京东滑块·京东逆向·京东变速滑块·cfe滑块·wasm逆向
_Evan_Yao1 小时前
为 LLM 预留“插座”:设计可插拔的 AI 能力底座
java·人工智能·后端·python
信看1 小时前
I2C 定位程序:LC29H/LC76G ZED-F9P
python