Make a list of your pip installed pacakages:
pip3 freeze > my_packages.txt
Uninstall python3.7:
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7
With your new install of python3.9, install the previous packages:
pip3 install -r my_packages.txt
Hope this helps.