Repository navigation
Closed
Labels
kind/bugSomething isn't working as expectedSomething isn't working as expectedkind/enhancementNot a bug or feature, but improves usability or performanceNot a bug or feature, but improves usability or performancestatus/triageThis issue needs to be triagedThis issue needs to be triaged
Description
- 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 (
-vvvoption).
- 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 #2388 because this error is produced when installing from the public PyPI repository. I believe this is not a duplicate of #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):
Reacted by Oleg Höfling, Yevgnen, Egor Turchinovich, Jeremy Richards, Thomas Buckley-Houston, occoder, Artur Przybysz, Connor Newton, Aaron ("AJ") Steers, Matt Stump and 9 more
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working as expectedSomething isn't working as expectedkind/enhancementNot a bug or feature, but improves usability or performanceNot a bug or feature, but improves usability or performancestatus/triageThis issue needs to be triagedThis issue needs to be triaged
Activity
sinoroc commentedon Nov 4, 2020
It could be a pip issue. At the point where the failure happens, it is pip that is running (in a subprocess created by poetry).
Are you downloading directly from PyPI? No private index, cache proxy or anything of the sort?
The error message shows the full path to the wheel file for pyarrow, maybe you could try to locate it and inspect it manually: see if it is a well formed zip file, and so on.
kylebarron commentedon Nov 4, 2020
Pip works fine when called directly.
Edit: it also works fine when not using the cached file:
sinoroc commentedon Nov 4, 2020
I do not think it is as simple as that. Anyway, it is a different pip. Check the version number in the stack trace:
Your stack trace shows this:
In case that file still exists on the file system, I would encourage you to have a look at it. Maybe poetry downloaded or wrote something wrong on disk.
kylebarron commentedon Nov 4, 2020
Trying to install the wheel file at that path directly (with the global pip) fails:
Also the md5sum (and file size) doesn't match the latest file on PyPI; 10MB vs 13MB on PyPI.
So I think what happened is that my internet cut out in the middle of the download, but the first 10MB was saved to the cache, and next time I tried to install pyarrow, that fragment was used for install. So it seems like either pip or poetry should check that local and remote hashes or file sizes match, and if not redownload the package?
[-]BadZipFile with public pypi package using new installer[/-][+]BadZipFile using cached incomplete download[/+]hoefling commentedon Nov 7, 2020
This error popped up after I aborted
poetry updatewhile still downloading the wheels; reproducible e.g. withtorch/tensorflowdependencies 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,
poetryprints the full path in the error message as can be seen in the above log. Thus:fixes the issue.
hoefling commentedon Nov 7, 2020
@finswimmer @kylebarron aside from hash comparison, downloading to a temp file and moving it to artifacts on success could be another improvement, e.g.
lobotmcj commentedon Jul 29, 2021
disabling the experimental new installer as recommended by abn here "fixed" this for me after I ran into the issue on several different occasions (and
cache clear pypi --alldid not help).sri-rang commentedon Sep 8, 2021
Local workaround for me was to remove the
~/.cache/pypoetry/artifactsand~..cache/pypoetry/cachefolders and runningpoetry installorpoetry update.earonesty commentedon Dec 20, 2021
disabling the experimental new installer also fixed this for me. downloading to a temp area and renaming is the right way to go.
poetry config experimental.new-installer falseearonesty commentedon Dec 20, 2021
mr that fixes this : #3301
earonesty commentedon Mar 2, 2022
is this a security/cert issue?
haolian9 commentedon Apr 18, 2022
yet another package failed to add due to this error:
neersighted commentedon Oct 11, 2022
Solved in cc3f994 -- we now don't make a file available in the cache until the download is complete.
github-actions commentedon Mar 1, 2024
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.