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

相关推荐
spencer_tseng8 分钟前
[j2cache ehcache.xml]/tmp/.ehcache-diskstore.lock (Permission denied)
xml·linux·python·ehcache·[j2cache
梦想不只是梦与想40 分钟前
Python Web 框架:FastAPI
python·fastapi·web框架
玩大数据的龙威1 小时前
农经权二轮延包—全面取代人工公示图生成
python·arcgis
岁月失语唯石能言1 小时前
《 Web项目测试实战:博客系统的功能/接口/自动化/性能全流程测试报告》
自动化测试·功能测试·selenium·jmeter·接口测试·压力测试·性能测试
IT_Octopus1 小时前
JSON 日志里的 `{“$ref“:“$.xxx“}`:从 fastjson 兼容包到原生 fastjson2 的迁移实录
开发语言·python·json
geovindu1 小时前
python:HandWriting Recognition using paddlepaddle
开发语言·后端·python·paddlepaddle
wuyk5552 小时前
Python 零基础入门第九章:用户输入与 While 循环
开发语言·python
兮动人2 小时前
Python变量与常量
开发语言·python·机器学习·python变量与常量
2601_962300812 小时前
机器学习的理想基石
人工智能·python·机器学习·编程语言·数据处理
Java后端的Ai之路2 小时前
21、Python - 命令模式
开发语言·人工智能·python·命令模式·外观模式