I use pyenv to manage my python versions as well as their virtual environments. Sometimes I ran into problems, of which the solution requires building python after installing certain dependencies.
So I simply run
pyenv uninstall 3.8.12
and install the dependencies required, then
pyenv install 3.8.12
however, this operation removes all the package installed along with the entire virtual environment under
pyenvrootdir/.pyenv/versions/3.8.12
in the previous version, like numpy or matplotlib.
So is there any way to remove, then re-build python, while those packages remains, so that I don't need to install them again?