AttributeError exception: "Object" NoneType "does not have a path attribute in

I am debugging python code (python2.7.12) as my code works, but I get NULL for all variables when streaming tweets to the database.

I got an error:

Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored 

I assume 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 commit_tweet_to_database() function is wrong ...

Do you have an idea ...? I would be grateful for any help!

Thanks.

+2
source share
4 answers
 Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored 

This indicates that the path attribute for the NoneType object was sent in the _remove function. NoneType objects have no attributes. You might need to take a look at the _remove function and start debugging from there.

0
source

I am also considering this error. I tried using the browser.close () method, and although it stops the object - โ€œNoneTypeโ€ does not have the โ€œpathโ€ attribute - from the displayed one I leave a bunch of open instances of the Firefox browser.

The .close () method closes chrome and it does not throw a NoneType error in firefox, but leaves Firefox open. The .quit () method closes both browsers, but it throws an error for firefox.

I am using the django class StaticLiveServerTestCase for my code.

I wrote a small debugger loop to check everything. Just uncomment and comment out the .quit () and .close () expressions.

 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.

+2
source

It sounds like this: although the try clause doesn't work, causing the exception to print? I'd rather add additional debugging to the catch Exception, for example, by printing out the arguments to commit_tweet_to_database to make sure that you are passing viable parameters.

0
source

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 an error message: object "NoneType" does not have attribute "path"

browser.quit ()

  • this following will not give an error

browser.close ()

So the problem is that you are using the wrong method for your object!

-1
source

Source: https://habr.com/ru/post/1260884/


All Articles