Python C:/startup/startupWebDriv-6ren">
gpt4 book ai didi

python - 未以管理员身份运行时出现 "cannot create temp dir for user data dir"错误

转载 作者:行者123 更新时间:2023-11-28 20:35:56 25 4
gpt4 key购买 nike

当我以管理员身份运行 python selenium 代码时,我只能运行它。如果我正常运行它,我会收到以下错误:

C:\startup>Python C:/startup/startupWebDriverScript.py    
Traceback (most recent call last):
File "C:/startup/startupWebDriverScript.py", line 26, in connectGuest
driver = webdriver.Chrome(chrome_options=chromeOptions,executable_path="C:/Python36/Chrome Webdriver/chromedriver.exe")
File "C:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot create temp dir for user data dir
(Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 10.0.15063 x86_64)

这是我的代码:

    chromeOptions = Options()
chromeOptions.add_argument("--use-fake-ui-for-media-stream")
chromeOptions.add_argument("--kiosk")
chromeOptions.add_argument("--disable-notifications")
chromeOptions.add_argument("--disable-infobars")
driver = webdriver.Chrome(chrome_options=chromeOptions,executable_path="C:/Python36/Chrome Webdriver/chromedriver.exe")

我正在使用 python 3.6、Windows 10 和 selenium 3.5

最佳答案

我遇到了同样的错误,但之前描述的内容对我没有任何帮助。我这样解决了问题:

  1. 在Windows命令行输入echo %temp%
  2. 它返回了C:\TEMP\2(为什么???)
  3. 所以我创建了这个文件夹,然后一切都开始工作了

关于python - 未以管理员身份运行时出现 "cannot create temp dir for user data dir"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46066670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com