Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python WebDriverException:消息:Can';不要加载配置文件。不知发生了什么事_Python_Selenium_Firefox - Fatal编程技术网

Python WebDriverException:消息:Can';不要加载配置文件。不知发生了什么事

Python WebDriverException:消息:Can';不要加载配置文件。不知发生了什么事,python,selenium,firefox,Python,Selenium,Firefox,我已经使用webdriver.Firefox()多年了,今天我开始了另一个项目,并且browser=webdriver.Firefox()正在返回 WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details. 我已尝试将C:\ProgramFiles(x

我已经使用webdriver.Firefox()多年了,今天我开始了另一个项目,并且
browser=webdriver.Firefox()
正在返回

WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
我已尝试将
C:\ProgramFiles(x86)\Mozilla Firefox\Firefox.exe
添加到我的路径中。我尝试了
pip安装-U selenium
。我试过了

binary = FirefoxBinary('C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe')
browser = webdriver.Firefox(firefox_binary=binary)

profile = FirefoxProfile("C:\Users\Me\AppData\Roaming\Mozilla\Firefox\Profiles\8u2w2ge1.Me")
browser = webdriver.Firefox(profile)
我已经将插件检查兼容性添加到我的firefox插件中。没有,没有工作,同样的错误,Python 2.7.11,Windows 10 x64

这是我得到的一般追踪

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    browser = webdriver.Firefox(firefox_binary=binary)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__
    self.binary, timeout)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 108, in _wait_until_connectable
    % (self.profile.path))
WebDriverException: Message: Can't load the profile. Profile Dir: c:\users\me\appdata\local\temp\tmpwvgny8 If you specified a log_file in the FirefoxBinary constructor, check it for details.
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
browser=webdriver.Firefox(Firefox\u binary=binary)
文件“C:\Python27\lib\site packages\selenium\webdriver\firefox\webdriver.py”,第80行,在\uuu init中__
self.binary,超时)
文件“C:\Python27\lib\site packages\selenium\webdriver\firefox\extension\u connection.py”,第52行,在\uuu init中__
self.binary.launch_浏览器(self.profile,timeout=timeout)
文件“C:\Python27\lib\site packages\selenium\webdriver\firefox\firefox\u binary.py”,第68行,在启动浏览器中
self.\u等待\u直到\u可连接(超时=超时)
文件“C:\Python27\lib\site packages\selenium\webdriver\firefox\firefox\u binary.py”,第108行,在可连接之前等待
%(self.profile.path)
WebDriverException:消息:无法加载配置文件。Profile Dir:c:\users\me\appdata\local\temp\tmpwvgny8如果您在FirefoxBinary构造函数中指定了日志文件,请查看它以了解详细信息。

有人知道为什么在临时目录中创建此配置文件时出现问题吗?因为我的旧方法不起作用,所以我用了一些新的方法将其强制应用到现有的配置文件中。

我实际上已经找到了一种解决方法,它并不完美,我实际上通过chromedriver使用chrome,因为它更稳定,但要使用firefox,您可能需要下载geckodriver,并将其包含在您的系统路径或浏览器设置的路径中,这似乎是他们发布版本的地方,chrome有一个功能,并且使用方式基本相同。我不知道为什么我们需要这些新的驱动程序在windows中使用selenium,但这就是生活,希望这能为其他人节省一些工作

您需要尝试将
C:\Program Files(x86)\Mozilla Firefox
添加到不带exe的路径。dir C:\users\me\appdata\local\temp\tmpwvgny8的结果是什么?是否需要来自此地址的配置文件:消息:无法加载配置文件。Profile Dir:c:\users\me\appdata\local\temp\tmpwvgny8?@randomInstanceOffingThing我删除了firefox.exe,得到了相同的结果。这是一个与我的普通个人资料非常相似的文件夹,请保存所有插件内容。@AbirKhan我相信是的,当我查看时,个人资料文件夹就在那里。