如何将 python x.x 更新为 python x.x 保留所有包?

How to update python x.x to python x.x keeping all the packages?

我是 python 3.8 用户。所以,为了保持更新,我想将我的 python 3.8 更新到 3.9。但是我在 python 3.8 中安装了大量的软件包。有什么方法可以保留软件包并更新 python 3.8 到 3.9?

import pip
from subprocess import call
for dist in pip.get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)