Python "Error 'dict' object has no attribute 'load'"
json, python, urllib2
Solution
You are storing the result of `json.load` in a variable named `json`, effectively overriding the module `json`. This is most likely not what you want to achieve. Try renaming that.
Problem
I am sort of new to Python and I've looked around for this, but basically what I'm making is an IRC bot. Now, the thing that's giving me an issue is a YouTube extract command I added. Here is the source: ``` if text.find(':'+prefix+'yt') != -1: idb = text.split(':'+prefix+'yt') videoid = idb[1].strip() if len(videoid) == 11: try: url = 'http://gdata.youtube.com/feeds/api/videos/'+videoid+'?alt=json&v=2' json = json.load(urllib2.urlopen(url)) title = json['entry']['title']['$t'] author = json['entry']['author'][0]['name']['$t'] irc.send('PRIVMSG '+home+' :'+str(title)+' | by '+str(author)+' | http://www.youtube.com/watch?v='+str(videoid)+' \r\n') except Exception, e: irc.send('PRIVMSG '+home+' :Could not look up video, check your ID. \r\n') print "Error",e pass else: irc.send('PRIVMSG '+home+' :Could not look up video, video ID must be at least 11 characters. \r\n'); ``` What happens is, the first try it works properly: ``` [14:57:23] <@Snowstormer> @yt Kwwl9jiJ1A4 [14:57:24] <GotBot> "Take Back the Night" - A Minecraft Original Music Video | by CaptainSparklez | http://www.youtube.com/watch?v=Kwwl9jiJ1A4 ``` However the next time it's: ``` [14:57:27] <@Snowstormer> @yt Kwwl9jiJ1A4 [14:57:27] <GotBot> Could not look up video, check your ID. ``` Which is only meant to show up if the ID is the proper length but a video with it doesn't exist. Before I added the Exception, the bot just straight up disconnected. In the CMD line it shows: ``` Error 'dict' object has no attribute 'load' ``` I tried Googling without a result. I am running Windows so no Unix-trickery will apply (if there is any, but I figured I should put it out there). I realize this might be bit of a localized question, but I do need help nevertheless.