BadZipFile using cached incomplete download
See original GitHub issue- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: macOS 10.15.6
- Poetry version: 1.1.4
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/kylebarron/7819f404c075ff1f1c1c7aa99d510def
Issue
Poetry install fails for the given pyproject.toml
(specifically with pyarrow 2.0.0) with the error zipfile.BadZipFile: File is not a zip file
. Install works fine when poetry config experimental.new-installer false
is set.
I believe this is not a duplicate of https://github.com/python-poetry/poetry/issues/2388 because this error is produced when installing from the public PyPI repository. I believe this is not a duplicate of https://github.com/python-poetry/poetry/issues/2674 because it persists after running poetry cache clear --all pypi
.
Full traceback:
Using virtualenv: /Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 1 install, 0 updates, 0 removals, 1 skipped
β’ Installing numpy (1.19.4): Skipped for the following reason: Already installed
β’ Installing pyarrow (2.0.0)
Stack trace:
7 ~/.poetry/lib/poetry/installation/executor.py:202 in _execute_operation
200β
201β try:
β 202β result = self._do_execute_operation(operation)
203β except EnvCommandError as e:
204β if e.e.returncode == -2:
6 ~/.poetry/lib/poetry/installation/executor.py:276 in _do_execute_operation
274β return 0
275β
β 276β result = getattr(self, "_execute_{}".format(method))(operation)
277β
278β if result != 0:
5 ~/.poetry/lib/poetry/installation/executor.py:411 in _execute_install
409β
410β def _execute_install(self, operation): # type: (Install) -> None
β 411β return self._install(operation)
412β
413β def _execute_update(self, operation): # type: (Update) -> None
4 ~/.poetry/lib/poetry/installation/executor.py:449 in _install
447β args.insert(2, "-U")
448β
β 449β return self.run_pip(*args)
450β
451β def _update(self, operation):
3 ~/.poetry/lib/poetry/installation/executor.py:300 in run_pip
298β def run_pip(self, *args, **kwargs): # type: (...) -> int
299β try:
β 300β self._env.run_pip(*args, **kwargs)
301β except EnvCommandError as e:
302β output = decode(e.e.output)
2 ~/.poetry/lib/poetry/utils/env.py:1042 in run_pip
1040β pip = self.get_pip_command()
1041β cmd = pip + list(args)
β 1042β return self._run(cmd, **kwargs)
1043β
1044β def _run(self, cmd, **kwargs):
1 ~/.poetry/lib/poetry/utils/env.py:1332 in _run
1330β self.unset_env("__PYVENV_LAUNCHER__")
1331β
β 1332β return super(VirtualEnv, self)._run(cmd, **kwargs)
1333β
1334β def execute(self, bin, *args, **kwargs):
EnvCommandError
Command ['/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/bin/pip', 'install', '--no-deps', 'file:///Users/kyle/Library/Caches/pypoetry/artifacts/ee/6f/d6/686cc5fcab3e5917f4baa20df3b737a0a33ec8f94b09724c03624424a9/pyarrow-2.0.0-cp37-cp37m-macosx_10_13_x86_64.whl'] errored with the following return code 2, and output:
Processing /Users/kyle/Library/Caches/pypoetry/artifacts/ee/6f/d6/686cc5fcab3e5917f4baa20df3b737a0a33ec8f94b09724c03624424a9/pyarrow-2.0.0-cp37-cp37m-macosx_10_13_x86_64.whl
ERROR: Exception:
Traceback (most recent call last):
File "/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 324, in run
reqs, check_supported_wheels=not options.target_dir
File "/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 391, in _resolve_one
dist = abstract_dist.get_pkg_resources_distribution()
File "/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/lib/python3.7/site-packages/pip/_internal/distributions/wheel.py", line 29, in get_pkg_resources_distribution
with ZipFile(self.req.local_file_path, allowZip64=True) as z:
File "/Users/kyle/local/anaconda3/lib/python3.7/zipfile.py", line 1258, in __init__
self._RealGetContents()
File "/Users/kyle/local/anaconda3/lib/python3.7/zipfile.py", line 1325, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
You should consider upgrading via the '/Users/kyle/Library/Caches/pypoetry/virtualenvs/tmp-2O282PEO-py3.7/bin/python -m pip install --upgrade pip' command.
at ~/.poetry/lib/poetry/utils/env.py:1074 in _run
1070β output = subprocess.check_output(
1071β cmd, stderr=subprocess.STDOUT, **kwargs
1072β )
1073β except CalledProcessError as e:
β 1074β raise EnvCommandError(e, input=input_)
1075β
1076β return decode(output)
1077β
1078β def execute(self, bin, *args, **kwargs):
Issue Analytics
- State:
- Created 3 years ago
- Reactions:18
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Hit ctrl-c during a pip install of spacy, now getting error when ...
At this point the installation is incomplete. Trying to install the package again with pip is now giving me an error, regardless of...
Read more >Partial file being downloaded - Akamai Community
When users from some other geography tries to download same file, it gets downloaded correctly entire 400MB. If we flush out the akamai...
Read more >File: tvdb_api.py | Debian Sources
useZip (bool): Download the zip archive where possibale, instead of the xml. ... BadZipfile: if 'x-local-cache' in resp.headers: resp.delete_cache() raiseΒ ...
Read more >Changelog β Python 3.11.1 documentation
gh-95818: Skip over incomplete frames in PyThreadState_GetFrame() . ... gh-90997: Show the actual named values stored in inline caches when show_caches=TrueΒ ...
Read more >zipfile.BadZipFile Example - Program Talk
"Please download manually from https://drive.google.com/drive/folders/" ... f'Archive file for "{id}" is corrupted') # add files in cache to update list forΒ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This error popped up after I aborted
poetry update
while still downloading the wheels; reproducible e.g. withtorch
/tensorflow
dependencies that are pretty large:The artifacts cache now contains broken dists, resulting in a
BadZipFile
:Clearing the cache indeed doesnβt remove the incomplete downloads. Luckily,
poetry
prints the full path in the error message as can be seen in the above log. Thus:fixes the issue.
Local workaround for me was to remove the
~/.cache/pypoetry/artifacts
and~..cache/pypoetry/cache
folders and runningpoetry install
orpoetry update
.