Search code examples
pythonpython-3.xseleniummatplotlibglob

Error during import matplotlib, glob, pylab because of geckodriver


When I am trying to import matplotlib or glob or pylab, it opens the geckodriver window and the geckodriver opens the firefox and opens google page on it. And after that , it gives an below error.

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

Solution

  • Your issue is obvious from below

      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')
    

    As you can see you have created your own glob.py file which is interfering with the import glob statement. You should never create file names which matches system level packages name and have them in python path also.

    Rename C:/Users/rahulku/AppData/Local/Programs/Python/Python36\glob.py to C:/Users/rahulku/AppData/Local/Programs/Python/Python36\glob_custom.py and that should fix the issue