{"action":"opened","issue":{"url":"https://api.github.com/repos/rossant/ipython-minibook/issues/3","labels_url":"https://api.github.com/repos/rossant/ipython-minibook/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/rossant/ipython-minibook/issues/3/comments","events_url":"https://api.github.com/repos/rossant/ipython-minibook/issues/3/events","html_url":"https://github.com/rossant/ipython-minibook/issues/3","id":59395929,"number":3,"title":"code in chapter 2 downloads a bad zipfile","user":{"login":"mmagnuski","id":8452354,"avatar_url":"https://avatars.githubusercontent.com/u/8452354?v=3","gravatar_id":"","url":"https://api.github.com/users/mmagnuski","html_url":"https://github.com/mmagnuski","followers_url":"https://api.github.com/users/mmagnuski/followers","following_url":"https://api.github.com/users/mmagnuski/following{/other_user}","gists_url":"https://api.github.com/users/mmagnuski/gists{/gist_id}","starred_url":"https://api.github.com/users/mmagnuski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmagnuski/subscriptions","organizations_url":"https://api.github.com/users/mmagnuski/orgs","repos_url":"https://api.github.com/users/mmagnuski/repos","events_url":"https://api.github.com/users/mmagnuski/events{/privacy}","received_events_url":"https://api.github.com/users/mmagnuski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-01T13:29:14Z","updated_at":"2015-03-01T13:29:14Z","closed_at":null,"body":"Hi Cyrille,\r\n\r\nIn chapter 2 there is a code that downloads a `facebook.zip` file:\r\n```python\r\nimport urllib2, zipfile\r\nurl = 'http://ipython.rossant.net/'\r\nfilename = 'facebook.zip'\r\n\r\ndownloaded = urllib2.urlopen(url + filename)\r\nwith open(filename, 'wb') as f:\r\n    f.write(downloaded.read())\r\n```\r\n\r\nFor some reason the code does not download a valid zip file. Running the next part of code gives `BadZipFile` error:\r\n```python\r\nwith zipfile.ZipFile(filename) as zip:\r\n    zip.extractall('.')\r\n```\r\nthe traceback:\r\n```python\r\n---------------------------------------------------------------------------\r\nBadZipfile                                Traceback (most recent call last)\r\n<ipython-input-10-091bb6db8a0d> in <module>()\r\n----> 1 with zipfile.ZipFile(filename) as zip:\r\n      2     zip.extractall('.')\r\n\r\nD:\\Python\\Anaconda\\lib\\zipfile.pyc in __init__(self, file, mode, compression, allowZip64)\r\n    768         try:\r\n    769             if key == 'r':\r\n--> 770                 self._RealGetContents()\r\n    771             elif key == 'w':\r\n    772                 # set the modified flag so central directory gets written\r\n\r\nD:\\Python\\Anaconda\\lib\\zipfile.pyc in _RealGetContents(self)\r\n    809             raise BadZipfile(\"File is not a zip file\")\r\n    810         if not endrec:\r\n--> 811             raise BadZipfile, \"File is not a zip file\"\r\n    812         if self.debug > 1:\r\n    813             print endrec\r\n\r\nBadZipfile: File is not a zip file\r\n```\r\n\r\nAt least this is what happens on my windows 8 machine.\r\nDownloading the file by hand (in Chorme) works well (no errors in the unzipping code).\r\n\r\nI have a 64-bit windows and 32-bit python (psychopy does not work with 64-bit python):\r\n```\r\nPython 2.7.7 :: Anaconda 2.0.1 (32-bit)\r\n```\r\nDo you think this could be the source of this problem?\r\n\r\n<sub>\r\nBTW:\r\nthanks for a great book! :+1: :+1: :+1:\r\n</sub>"}}