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

相关推荐
一晌小贪欢22 分钟前
【Python办公】用 Selenium 自动化网页批量录入
开发语言·python·selenium·自动化·python3·python学习·网页自动化
诸神缄默不语1 小时前
如何用Python处理文件:Word导出PDF & 如何用Python从Word中提取数据:以处理简历为例
python·pdf·word
vvoennvv1 小时前
【Python TensorFlow】 TCN-LSTM时间序列卷积长短期记忆神经网络时序预测算法(附代码)
python·神经网络·机器学习·tensorflow·lstm·tcn
nix.gnehc1 小时前
PyTorch
人工智能·pytorch·python
z***3352 小时前
SQL Server2022版+SSMS安装教程(保姆级)
后端·python·flask
I'm Jie2 小时前
从零开始学习 TOML,配置文件的新选择
python·properties·yaml·toml
二川bro3 小时前
Scikit-learn全流程指南:Python机器学习项目实战
python·机器学习·scikit-learn
代码的乐趣3 小时前
支持selenium的chrome driver更新到142.0.7444.175
chrome·python·selenium
数据知道3 小时前
Django基础项目:从零到一搭建用户管理系统
python·django·python web·python项目