Skip to content Skip to sidebar Skip to footer

AttributeError: 'NoneType' Object Has No Attribute 'close'

I am new to python js I am trying to run a project that are available on github but when I am trying to run it gives following error Traceback (most recent call last): File 'ma

Solution 1:

My guess would be that both attempts to create a driver - PhantomJS and FireFox - fail, meaning that driver is still None when you reach the finally block. You could confirm this by adding an explicit check:

    finally:
        if driver:
            driver.close()
        else:
            print "Could not create driver"

As to why driver creation would be failing, the most likely explanation is an installation problem. You can test this by running a trivial example in your Python environment:

>>> from selenium.webdriver import Firefox
>>> d = Firefox()
>>> d.get('http://stackoverflow.com')

If this doesn't open Firefox and navigate to the front page of Stack Overflow, check the Selenium documentation for your OS.


Solution 2:


Solution 3:

if both the try ...except clause failed in crawler_machine, the global value of driver will be None.


Post a Comment for "AttributeError: 'NoneType' Object Has No Attribute 'close'"