当不作为管理员

问题描述:

运行,我只是能当我运行它以管理员身份运行我的Python代码硒“无法创建用户数据目录临时目录”的错误。如果我运行它通常我得到以下错误:当不作为管理员

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和基于我的经验硒3.5

,您可能遇到以下情况之一。
1)您的磁盘已满,因此没有足够的可用磁盘空间。尝试清空回收站或检查过度生成的临时文件并清除它们。

2),或已安装使用管理员权限的包,因此你的脚本没有正确的权限来执行。

3)TMP环境变量可能需要修改。
右键单击计算机,然后单击属性 - >高级系统设置 - >环境变量 - “为用户变量”>
并更改TEMP和TMP瓦尔值“C:\ TEMP”。

尝试了很多不同的方法后,我决定降级的Chrome网络驱动程序,它开始工作了罚款。

+0

差不多好奇,想知道哪个日志/效应触发降级的'chromedriver'的想法? – DebanjanB

+0

其实我将我的设置与另一个类似的工作设置进行了比较,唯一的区别是铬合金驱动程序版本。不幸的是,我不明白底层问题究竟是什么。 –