由于geckodriver

时间:2017-09-30 19:38:17

标签: python python-3.x selenium matplotlib glob

当我尝试导入matplotlib或glob或pylab时,它会打开geckodriver窗口,geckodriver打开firefox并在其上打开google页面。 之后,它会出现以下错误。

Traceback (most recent call last):
  File "<pyshell#27>", line 1, in <module>
    from pylab import *
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\cbook.py", line 19, in <module>
    import glob
  File "C:/Users/rahulku/AppData/Local/Programs/Python/Python36\glob.py", line 13, in <module>
    driver = webdriver.Firefox(executable_path=r'C:\Users\rahulku\AppData\Local\Temp\geckodriver.exe')
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 154, in __init__
    keep_alive=True)
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\rahulku\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
    self.error_handler.check_response(response)
  File "C:\Users\rahulku\AppData\Local\Programs\Python\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: Failed to start browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe: other os error

1 个答案:

答案 0 :(得分:0)

您的问题从下面显而易见

<nav class="navbar navbar-custom">
  <ul class="nav navbar-nav navbar-right">
    <button class="btn sixth">SIGN UP</button>
  </ul>
</nav>

正如您所看到的,您创建了自己的 File "C:/Users/rahulku/AppData/Local/Programs/Python/Python36\glob.py", line 13, in <module> driver = webdriver.Firefox(executable_path=r'C:\Users\rahulku\AppData\Local\Temp\geckodriver.exe') 文件,该文件干扰了glob.py语句。您永远不应该创建与系统级软件包名称匹配的文件名,并且也应该在python路径中使用它们。

import glob重命名为C:/Users/rahulku/AppData/Local/Programs/Python/Python36\glob.py,这应解决问题