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

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包成功

最近更新

  1. TCP协议是安全的吗?

    2024-04-28 16:00:02       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-28 16:00:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-28 16:00:02       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-28 16:00:02       20 阅读

热门阅读

  1. 如何有效的开展接口自动化测试?

    2024-04-28 16:00:02       12 阅读
  2. sqlite3

    2024-04-28 16:00:02       14 阅读
  3. MATLAB初学者入门(21)—— 霍夫曼树

    2024-04-28 16:00:02       10 阅读
  4. .NET/C#汇总 —— 常⻅的算法

    2024-04-28 16:00:02       11 阅读
  5. 前端工程化-简介

    2024-04-28 16:00:02       10 阅读
  6. 外贸常用邮件模板-客户投诉要如何处理?

    2024-04-28 16:00:02       16 阅读
  7. leetcode刷题笔记——使用双指针处理链表问题

    2024-04-28 16:00:02       12 阅读
  8. Vue入门到关门之指令系统

    2024-04-28 16:00:02       11 阅读
  9. GateWay具体的使用之全局token过滤器

    2024-04-28 16:00:02       13 阅读