【问题标题】:python Selenium PermissionError: [WinError 5] Access is deniedpython Selenium PermissionError: [WinError 5] 访问被拒绝
【发布时间】:2016-12-21 22:37:01
【问题描述】:

我正在尝试使用 python Selenium 打开 Internet Explorer,但不断收到错误“PermissionError: [WinError 5] Access is denied”。

我已下载 Internet Explorer Driver Server 以管理员身份运行脚本,我还能做些什么吗?

代码

from selenium import webdriver

driver = webdriver.Ie(r"C:\\Users\\N\\Downloads\\IEwebdriver\\IEDriverServer_x64_2.53.1")
driver.get("http://www.hotmail.com")
driver.maximize_window()
driver.implicitly_wait(20)

完整的错误信息

C:\Users\N\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/N/PycharmProjects/first/SeleniumScripts/Myfirstscripts.py
Traceback (most recent call last):
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

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

Traceback (most recent call last):
  File "C:/Users/N/PycharmProjects/first/SeleniumScripts/Myfirstscripts.py", line 5, in <module>
    driver = webdriver.Ie(r"C:\\Users\\N\\Downloads\\IEwebdriver\\IEDriverServer_x64_2.53.1")
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 49, in __init__
    self.iedriver.start()
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'IEDriverServer_x64_2.53.1' executable may have wrong permissions. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.ie.service.Service object at 0x01C9D410>>
Traceback (most recent call last):
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
    self.stop()
  File "C:\Users\N\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

Process finished with exit code 1

我使用的是 Microsoft Windows 10。

【问题讨论】:

标签: python python-3.x selenium


【解决方案1】:

驱动程序没有指向 exe 文件!所以它应该是。

driver = webdriver.Ie(r"C:\\Users\\N\\Downloads\\IEwebdriver\\IEDriverServer_x64_2.53.1\\IEDriverServer.exe")

【讨论】:

    【解决方案2】:

    如果你不打算设置环境变量PATH,你应该把它直接指向.exe文件而不是子文件夹

    driver=webdriver.Ie(r"C:\\Users\\N\\Downloads\\IEwebdriver\\IEDriverServer_x64_2.53.1\\IEDriverServer_x64_2.53.1.exe"
    

    【讨论】:

      【解决方案3】:

      下载适用于您的 chrome 版本的驱动程序,并将其放在您的 chrome 路径中。

      http://chromedriver.chromium.org/downloads

      【讨论】:

        猜你喜欢
        • 2020-05-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-13
        • 2023-03-27
        • 2022-11-04
        • 2018-02-10
        相关资源
        最近更新 更多