Setuptools: zipfile.BadZipfile: File is not a zip file

Created on 2 Jun 2016  Β·  5Comments  Β·  Source: pypa/setuptools

$ wget https://bootstrap.pypa.io/ez_setup.py
$ python ez_setup.py 
Downloading https://pypi.io/packages/source/s/setuptools/setuptools-22.0.0.zip
Extracting in /tmp/tmptxdourqa
Traceback (most recent call last):
  File "ez_setup.py", line 425, in <module>
    sys.exit(main())
  File "ez_setup.py", line 422, in main
    return _install(archive, _build_install_args(options))
  File "ez_setup.py", line 56, in _install
    with archive_context(archive_filename):
  File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "ez_setup.py", line 107, in archive_context
    with ContextualZipFile(filename) as archive:
  File "ez_setup.py", line 91, in __new__
    return zipfile.ZipFile(*args, **kwargs)
  File "/usr/lib/python3.5/zipfile.py", line 1026, in __init__
    self._RealGetContents()
  File "/usr/lib/python3.5/zipfile.py", line 1093, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

Most helpful comment

The zip is now there. I expect the issue to be fixed now. Let me know if you find otherwise.

All 5 comments

Yep, same problem here. Also these:

$ wget https://pypi.io/packages/source/s/setuptools/setuptools-22.0.0.zip
--2016-06-02 11:54:13--  https://pypi.io/packages/source/s/setuptools/setuptools-22.0.0.zip
Resolving pypi.io (pypi.io)... 151.101.64.223, 151.101.192.223, 151.101.128.223, ...
Connecting to pypi.io (pypi.io)|151.101.64.223|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-22.0.0.zip [following]
--2016-06-02 11:54:13--  https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-22.0.0.zip
Resolving files.pythonhosted.org (files.pythonhosted.org)... 172.111.75.6
Connecting to files.pythonhosted.org (files.pythonhosted.org)|172.111.75.6|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-06-02 11:54:13 ERROR 404: Not Found.
$ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
--2016-06-02 11:49:09--  https://bootstrap.pypa.io/ez_setup.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 185.31.19.175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|185.31.19.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12385 (12K) [text/x-python]
Saving to: β€˜STDOUT’

100%[====================================================================================================================>] 12,385      --.-K/s   in 0.001s  

2016-06-02 11:49:09 (14.7 MB/s) - written to stdout [12385/12385]

Downloading https://pypi.io/packages/source/s/setuptools/setuptools-22.0.0.zip
Extracting in /tmp/tmpRrfLQI
Traceback (most recent call last):
  File "<stdin>", line 425, in <module>
  File "<stdin>", line 422, in main
  File "<stdin>", line 56, in _install
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "<stdin>", line 107, in archive_context
  File "<stdin>", line 91, in __new__
  File "/usr/lib/python2.7/zipfile.py", line 756, in __init__
    self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: '/home/flyte/setuptools-22.0.0.zip'

Also this:

sudo pip install --upgrade setuptools
[sudo] password for flyte: 
The directory '/home/flyte/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/flyte/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting setuptools
  Downloading setuptools-22.0.0-py2.py3-none-any.whl (509kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 512kB 2.4MB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 21.0.0
    Uninstalling setuptools-21.0.0:
      Successfully uninstalled setuptools-21.0.0
Successfully installed setuptools
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 221, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 252, in main
    pip_version_check(session)
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/outdated.py", line 102, in pip_version_check
    installed_version = get_installed_version("pip")
  File "/usr/local/lib/python2.7/dist-packages/pip/utils/__init__.py", line 848, in get_installed_version
    working_set = pkg_resources.WorkingSet()
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 619, in __init__
    self.add_entry(entry)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 675, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1942, in find_eggs_in_zip
    if metadata.has_metadata('PKG-INFO'):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1463, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1824, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1704, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 1644, in load
    mtime = os.stat(path).st_mtime
OSError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/setuptools-21.0.0-py2.7.egg'

However, easy_install does work:

$ sudo easy_install --upgrade setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Best match: setuptools 22.0.0
Downloading https://pypi.python.org/packages/f5/90/010892bde11d2da00548285da29a055e6b0e3b81592bb6021571b87f34a1/setuptools-22.0.0.tar.gz#md5=ddd9fbe3da4ac564830d75fadf796930
Processing setuptools-22.0.0.tar.gz
Writing /tmp/easy_install-vZiiyf/setuptools-22.0.0/setup.cfg
Running setuptools-22.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vZiiyf/setuptools-22.0.0/egg-dist-tmp-mOls4t
warning: no files found matching '*' under directory 'setuptools/_vendor'
Moving setuptools-22.0.0-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding setuptools 22.0.0 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/setuptools-22.0.0-py2.7.egg
Processing dependencies for setuptools
Finished processing dependencies for setuptools

The PyPI is missing the zip file at https://pypi.python.org/pypi/setuptools/22.0.0. Another manifestation of #589 most likely. I'll re-upload the zip.

The zip is now there. I expect the issue to be fixed now. Let me know if you find otherwise.

Same error with version 24.0.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rickstaa picture rickstaa  Β·  5Comments

Tobotimus picture Tobotimus  Β·  4Comments

Gumnos picture Gumnos  Β·  4Comments

jakirkham picture jakirkham  Β·  6Comments

cnseu picture cnseu  Β·  5Comments