I am debugging python code (python2.7.12) as my code works but I get NULL for all variables when streaming tweets into the database.
The error I got is:
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored
I am assuming this error is from the code below:
def put_tweets_in_database(tweets):
print "putting tweets in database"
errors = 0
count = 0
for tweet in tweets:
try:
commit_tweet_to_database(tweet, count, len(tweets))
count += 1
except Exception as e:
print e
session.rollback()
errors += 1
print 'there were {} errors'.format(errors)
I don't think the function commit_tweet_to_database()
is wrong...
Do you have any idea...? I would appreciate any help!
Thank you.
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored
This tells that in function _remove
an attribute path
was tried to be accessed on a NoneType
object. NoneType
objects have no attributes. So may be you need to look at _remove
function and start debugging from there.
I am also dealing with this error. I tried using the browser.close() method, and while it does stop the - 'NoneType' object has no attribute 'path' - from being displayed, I am left with a bunch of open firefox browser instances.
The .close() method closes chrome, and it doesn't throw the NoneType error in firefox, but it leaves firefox open. The .quit() method closes both browsers, but it throws the error for firefox.
I am using django's StaticLiveServerTestCase class for my code.
I wrote a little debugger loop to test things out. Just uncomment and comment out the .quit() and .close() statements.
class BaseTestCase(StaticLiveServerTestCase):
@classmethod
def setUp(self):
self.firefox = webdriver.Firefox()
self.chrome = webdriver.Chrome()
self.browsers = [self.firefox, self.chrome]
@classmethod
def tearDown(self):
for browser in self.browsers:
if browser == self.firefox:
print('firefox')
browser.close()
# browser.quit()
elif browser == self.chrome:
print('chrome')
browser.close()
# browser.quit()
I still don't know the answer, but I think this is a step in the right direction.
It sounds as-though your "try" clause is failing, causing the exception to be printed? I'd likely add more debugging to the Exception catch, such as printing out the arguments to commit_tweet_to_database, just to make sure you're passing viable parameters.
Try removing this line of code:
import pdb;pdb.set_trace()
Guess the script already called pdb.set_trace()
and you are trying to override it. This might be a reason for the issue.
I have the same error and here is my case:
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print browser.title
- this following will give me error message: 'NoneType' object has no attribute 'path'
browser.quit()
- this following will not give error
browser.close()
So the issue is that you have use the wrong method for your object!