title: BadZipFile: File is not a zip file error in Jupyter notebook in python
body: <p>How to solve the &quot;BadZipFile: File is not a zip file&quot;  error?</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd             
  import matplotlib.pyplot as plt 
  import datetime as dt
  import numpy as np
  
  # these are new 
  import requests, io             
  import zipfile as zf            
  import shutil                    
  import os                       
  
  from census import Census 
  
  import geopandas as gpd 
  from shapely.geometry import Point, Polygon # also needed
  
  import pyarrow as pa
  import pyarrow.parquet as pq
  
  print(&quot;&quot;)
  print(&quot;**********************************************************************************&quot;)
  print(&quot;Downloading Shape files&quot;)
  print(&quot;&quot;)
  
  cwd = os.getcwd()
  
  county_url = &quot;https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_lakes.zip&quot;
      
  r = requests.get(county_url ) 
  
  lake_shapefile = zf.ZipFile(io.BytesIO(r.content)) 
  
  lake_shapefile.extractall(path = cwd + &quot;\\shapefiles\\lake&quot;)
  
  del r, lake_shapefile
  </code></pre>
  <p>Error:</p>
  <pre><code>**********************************************************************************
  Downloading Shape files
  
  ---------------------------------------------------------------------------
  BadZipFile                                Traceback (most recent call last)
  &lt;ipython-input-4-34cf0e97a55d&gt; in &lt;module&gt;
       10 r = requests.get(county_url )
       11 
  ---&gt; 12 lake_shapefile = zf.ZipFile(io.BytesIO(r.content))
       13 
       14 lake_shapefile.extractall(path = cwd + &quot;\\shapefiles\\lake&quot;)
  
  ~/opt/anaconda3/lib/python3.7/zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel)
     1223         try:
     1224             if mode == 'r':
  -&gt; 1225                 self._RealGetContents()
     1226             elif mode in ('w', 'x'):
     1227                 # set the modified flag so central directory gets written
  
  ~/opt/anaconda3/lib/python3.7/zipfile.py in _RealGetContents(self)
     1290             raise BadZipFile(&quot;File is not a zip file&quot;)
     1291         if not endrec:
  -&gt; 1292             raise BadZipFile(&quot;File is not a zip file&quot;)
     1293         if self.debug &gt; 1:
     1294             print(endrec)
  
  BadZipFile: File is not a zip file
  
  </code></pre>