I am running python on windows in sublime text. When i wanted to work with the zipfile module I get this error ImportError: No module named 'ZipFile'. I tried changing the name to zipfile from Zipfile with no success. I looked at my pythonpath variable it does show the location of the lib folder where zipfile.py is located. I am unsure of what is going wrong. Any help or clue with what is going on is appreciated.
import urllib.request
import ZipFile
import StringIO
url = 'some_url'
z = ZipFile(StringIO.StringIO(urllib.request.urlopen(url).read()))
z.extractall()
Even running in python ide gives me the same error
The name of the module is zipfile
. Also you need to use io.BytesIO
. (There's no StringIO
module in Python 3.x; I guesses you use Python 3 .x because of urllib.request
)
import urllib.request
import zipfile
from io import BytesIO
url = 'some_url'
z = zipfile.ZipFile(BytesIO(urllib.request.urlopen(url).read()))
z.extractall()