【问题标题】:Permission error [winerror 5] access is denied-Selenium chrome webdriver权限错误【winerror 5】访问被拒绝-Selenium chrome webdriver
【发布时间】:2021-01-15 14:31:29
【问题描述】:

我正在学习使用 selenium 的教程,但我在开始时遇到了问题。也就是说,当我尝试运行下面的代码时,我得到下面的错误。我看到其他用户有同样的问题,我尝试了他们的解决方案,但他们没有工作。

这些解决方案包括:

  • 以管理员身份运行 pycharm,
  • 为所有人设置权限
  • subprocess.py 和 service.py 的组/用户名
  • 站点包(以及其中的几乎每个文件/文件夹)已满 访问。
from selenium import webdriver
driver = webdriver.Chrome(r"C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\selenium\webdriver\chrome")
driver.get("http://python.org")

这是完整的错误信息:

Traceback(最近一次调用最后一次):文件 "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", 第 76 行,开始 stdin=PIPE) 文件 "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", 第 775 行,在 init 中 restore_signals, start_new_session) 文件 "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", 第 1178 行,在 _execute_child 中 startupinfo) PermissionError: [WinError 5] 访问被拒绝

在处理上述异常的过程中,又发生了一个异常:

Traceback(最近一次调用最后一次):文件 “C:/Users/User/PycharmProjects/PythonProject/DataCollection”,第 2 行, 在 驱动程序 = webdriver.Chrome(r"C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\selenium\webdriver\chrome") 文件 "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", 第 73 行,在 init 中 self.service.start() 文件 "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", 第 88 行,开始 os.path.basename(self.path),self.start_error_message)selenium.common.exceptions.WebDriverException:消息:'chrome' 可执行文件可能有错误的权限。请参见 https://sites.google.com/a/chromium.org/chromedriver/home

【问题讨论】:

    标签: python selenium-webdriver


    【解决方案1】:

    首先,将所有\ 替换为/

    然后在文件位置添加可执行文件名:

    driver = webdriver.Chrome(r'C:/Users/User/AppData/Local/Programs/Python/Python37-32/Lib/site-packages/selenium/webdriver/chrome/chromedriver.exe')
    

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 2018-02-10
      • 2020-05-03
      • 2016-11-06
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多