Save/restore cache ignoring a directory?

I’m trying to set up a linting job using flake8 to check some python code. I’m installing requirements and then saving them to a cache to speed up the build. This works fine the first time through the workflow (when not using the cache), and I can run flake8 . successfully. However when the cache is used, flake8 isn’t found as a command. I can see that when flake8 is installed, it adds a shim at /home/circleci/.pyenv/shims/flake8. So I have tried adding the shims directory to save_cache. But when the cache is restored, that directory doesn’t seem to include the added files (eg a flake8 entry). Is this directory not cacheable? Is there a way to restore the pyenv shims correctly so that flake8 can be found on subsequent runs?

      - save_cache:
          key: core-requirements-v5-{{ checksum "requirements.txt" }}
          paths:
            - /home/circleci/.pyenv/versions/3.9.6/lib/python3.9/site-packages
            - /home/circleci/.pyenv/shims

I tried to get around this by calling commands directly with eg python -m flake8 and python -m pytest, but it then breaks on other things out of my control (like migrations calling alembic directly). So do seem to need a way to either restore the shims, or regenerate them, without having to do a clean install of requirements.