简体   繁体   English

python Selenium PermissionError:[WinError 5]访问被拒绝

[英]python Selenium PermissionError: [WinError 5] Access is denied

I'm trying to open up a Internet Explorer with python Selenium but keep getting an error " PermissionError: [WinError 5] Access is denied ". 我正在尝试使用python Selenium打开Internet Explorer,但始终收到错误“ PermissionError:[WinError 5]访问被拒绝 ”。

I have downloaded Internet Explorer Driver Server ran the script as administrator is there anything else I could do? 我已经下载了Internet Explorer驱动程序服务器,并且以管理员身份运行了脚本,我还能做点什么?

Code

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)

The full error message 完整的错误信息

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

During handling of the above exception, another exception occurred: 在处理上述异常期间,发生了另一个异常:

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

I'm using Microsoft Windows 10. 我正在使用Microsoft Windows 10。

The driver wasn't pointing at the exe file! 驱动程序没有指向exe文件! so it should of been. 所以应该如此。

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

如果您不打算设置环境变量PATH,则应将其直接指向.exe文件而不是子文件夹。

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

Download the driver for your chrome version, and place it on your chrome path. 下载适用于您的chrome版本的驱动程序,并将其放在chrome路径中。

http://chromedriver.chromium.org/downloads http://chromedriver.chromium.org/downloads

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM