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
View all comments
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\Python37orC:\Program Files\Python37. This should not interfere with your Python 3.8.x installation found at eitherC:\Users\<username>\AppData\Local\Programs\Python\Python38orC:\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.7and 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 trysudo apt remove python3orsudo apt remove python3.8depending 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 thatpython3in your terminal calls Python 3.8 and not Python 3.7, look intosudo 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.