I am trying to install the package ansible (version 2.9.27 specifically) on a python 3.6.8 virtual environment. I am getting the following error:
Looking in indexes: https://pypi.org/simple/
Collecting ansible==2.9.27
Using cached ansible-2.9.27-py3-none-any.whl
ERROR: Exception:
Traceback (most recent call last):
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
status = run_func(*args)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
return func(self, options, args)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/commands/install.py", line 339, in run
reqs, check_supported_wheels=not options.target_dir
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 93, in resolve
collected.requirements, max_rounds=try_to_avoid_resolution_too_deep
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 482, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 349, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173, in _add_to_criteria
if not criterion.candidates:
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
return bool(self._sequence)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
return any(self)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
candidate = func()
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
version=version,
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 287, in __init__
version=version,
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
self.dist = self._prepare()
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
dist = self._prepare_distribution()
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/operations/prepare.py", line 550, in _prepare_linked_requirement
self.build_isolation,
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/operations/prepare.py", line 59, in _get_prepared_distribution
return abstract_dist.get_metadata_distribution()
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/distributions/wheel.py", line 26, in get_metadata_distribution
return get_wheel_distribution(wheel, canonicalize_name(self.req.name))
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/metadata/__init__.py", line 51, in get_wheel_distribution
return Distribution.from_wheel(wheel, canonical_name)
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/metadata/pkg_resources.py", line 37, in from_wheel
with wheel.as_zipfile() as zf:
File "/opt/dev/automated_golive/development/custom-python3-ansible-299/lib64/python3.6/site-packages/pip/_internal/metadata/base.py", line 321, in as_zipfile
return zipfile.ZipFile(self.location, allowZip64=True)
File "/usr/lib64/python3.6/zipfile.py", line 1131, in __init__
self._RealGetContents()
File "/usr/lib64/python3.6/zipfile.py", line 1198, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
The installation works fine for later versions of the ansible package.
What's going wrong here?
PS: I realize that I am trying an EOL version of Ansible on a Python version that is also no longer supported by the Ansible project.
It turns out to be an issue with the cached package. pip was loading the file from cache:
Using cached ansible-2.9.27-py3-none-any.whl
The installation goes successfully when you bypass the cache:
pip install ansible==2.9.27 --no-cache-dir
Or as pointed in the commend by @FlyingTeller, we can purge the cache before proceeding with the install:
pip cache purge
pip install ansible==2.9.27