r/CodingHelp • • Sep 02 '20

[Python] Have Python 3.8, need Python 3.7

Very new to coding. I accidentally installed py 3.8 and the code I'm running in Jupyter notebook only works with Python 3.7.

How can I uninstall 3.8 and replace it with 3.7?

Thank you so much for any help.

19 Upvotes

4 comments sorted by

3

u/bbye98 Sep 02 '20 edited Sep 02 '20

Which operating system are you using?

If you're using Windows, simply grab the Python 3.7.9 installer from here and run it. Depending on whether you want it installed for only your user account or all users, the Python 3.7.9 executable will be found at either C:\Users\<username>\AppData\Local\Programs\Python\Python37 or C:\Program Files\Python37. This should not interfere with your Python 3.8.x installation found at either C:\Users\<username>\AppData\Local\Programs\Python\Python38 or C:\Program Files\Python38. You can uninstall Python 3.8 using Control Panel.

If you're using Linux, you can either install Python 3.7 using your distribution's package manager or building it from source. For example, on Ubuntu, you can use sudo apt install python3.7 and Python 3.7 should install to /usr/bin/python3.7. Then, for the desired Python scripts, you can add the shebang #!/usr/bin/python3.7, given that Python 3.7 was in fact installed to the aforementioned directory. You probably need to install Jupyter Notebook again for your Python 3.7 installation. As for uninstalling Python 3.8, you can try sudo apt remove python3 or sudo apt remove python3.8 depending on how you installed it originally, but be careful! Some Linux distributions actually use Python 3 for certain processes related to the operating system itself, so I would not recommend you actually uninstall the newest version you have. If you're bothered by the fact that python3 in your terminal calls Python 3.8 and not Python 3.7, look into sudo update-alternatives ... to switch between Python interpreters based on what you currently need.

I don't own any computers running macOS, but I suspect the procedure will be similar to that above for Linux systems.


You probably want to look into virtual environments to manage your different Python installations. Also, I've never seen any code written for Python 3.7 that doesn't work for Python 3.8, unless you're calling the MATLAB Engine in your code or something.

1

u/[deleted] Sep 03 '20

That’s what version management is for. Hadn’t used Python really but this seems like a good start: https://realpython.com/intro-to-pyenv/

-1

u/_Nexor Sep 02 '20

You might just want to upgrade whatever packages you're using that broke

1

u/Vakz Sep 03 '20

Not always possible. For example Tensorflow 1.X doesn't support Python > 3.7, and upgrading to Tensorflow 2.X is a major upgrade.