【问题标题】:Python WebDriver - ChromeDriver.exe not working asking me for some permissions(!?)Python WebDriver - ChromeDriver.exe 不工作,要求我提供一些权限(!?)
【发布时间】:2020-02-06 00:44:13
【问题描述】:

我有这个代码,但它以这个错误结束......

    driver = webdriver.Chrome('C:\webdrivers\chromedriver.exe')
    blablabla  ....
    OSError: [WinError 740] The requested operation requires elevation

我对该文件夹授予了完全权限,并在 pycharm、py 文件和 chromedriver.exe 上以管理员身份运行,但没有任何效果......

  • 我确实有 Windows,但我没有看到很多人在 Windows 上使用“webdriver”。也许正是因为这个?想...
  • 这个“TinderBot”是因为我关注这个 youtube tut...

我的代码

from selenium import webdriver
import chromedriver_binary

driver = webdriver.Chrome('C:\webdrivers\chromedriver.exe')
driver.get("http://www.python.org")

完全错误

  G:\school\Python\PJ\TinderBot\Scripts\python.exe G:/school/Python/PJ/gui/TinderBot/main.py
Traceback (most recent call last):
  File "G:/school/Python/PJ/gui/TinderBot/main.py", line 31, in <module>
    driver = webdriver.Chrome('C:\webdrivers\chromedriver.exe')
  File "G:\school\Python\PJ\TinderBot\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "G:\school\Python\PJ\TinderBot\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\Azoul\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Azoul\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 740] The requested operation requires elevation

Process finished with exit code 1

非常感谢!

【问题讨论】:

  • 不要以管理员身份运行此代码
  • 我还能做什么?
  • 您使用哪些 chrome 和 chromedriver 版本?导致最新的稳定版本现在不兼容。

标签: python google-chrome webdriver


【解决方案1】:

以管理员身份运行Pycharm,然后运行。它对我有用。 最初,它是在我的 C 盘而不是 D 盘上工作的。以管理员身份打开后,它起作用了。

您可以尝试的另一件事是 PATH,或者您可以将驱动程序放在 Python..\Scripts 文件夹中,然后可以触发 chrome 而无需提及如下任何位置: enter image description here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多