We follow the the recommendations for using a pipenv cache with python projects nearly exactly to the letter, with the exception that we use
pipenv sync instead of
This used to work like a charm, but since a few days caches seem to be corrupted, and we have to invalidate the cache each run. The error we’re getting this that pip cannot be found.
in <module>', ' from pip._internal.cli.main import main', "ModuleNotFoundError: No module named pip
This is caused by pip somehow being symlinked to a location outside of the project directory. This location doesn’t get cached, and hence pipenv will fail when run from a restored cache. The symlink that pip points to:
$ ls -alhtr .venv/lib/python3.7/site-packages/pip lrwxrwxrwx 1 circleci circleci 106 Feb 11 15:01 .venv/lib/python3.7/site-packages/pip -> /home/circleci/.local/share/virtualenv/seed-v1/3.7/image/SymlinkPipInstall/pip-20.0.2-py2.py3-none-any/pip
This does not happen on older image digests, where pip happily lives in
.venv/lib/python3.7/site-packages/pip. The latest image digest (of tag python:3.7) that we find working is: