I’m diving into some Python projects, and I really need your help. So, I recently installed Python 3.8 on my Ubuntu 20.04 system, but I’ve noticed that when I run Python from the terminal, it’s still defaulting to Python 3.6. I’ve read a bit about how to change the default version, but there are so many tutorials out there, and I’m worried I might mess something up in the process.
I’ve tried a couple of things, like just updating the alternatives with the command `update-alternatives`, but honestly, I’m not even sure if I did it right. I also looked into .bashrc and modifying the PATH variable, but to be frank, that sounds a bit risky for this complete novice! I definitely don’t want to break my current environment or make my system unable to run Python at all, you know?
What I really need are some clear, step-by-step instructions from those who have navigated this before. Like, should I just uninstall the older version first? Or is it better to leave it there just in case I accidentally need it later? Also, what about pip? I heard there might be some things I need to tweak to make sure that also references the right version of Python.
I’ve been scanning forums and tech blogs, but they tend to be overly complicated or assume a level of expertise that I just don’t have yet. So, if you’ve gone through setting Python 3.8 as the default on Ubuntu 20.04, could you share the specific commands you used or any tips that made the process smoother for you? Maybe even pitfalls to avoid? I just want to make sure that I get it right and can start using Python 3.8 without any hassle. Any guidance would be super appreciated!
Setting Python 3.8 as Default
If you want to use Python 3.8 as your default version, here’s a simple step-by-step guide that can help you do that without any hassle!
Step 1: Check Your Python Versions
First, let’s check which versions of Python you have installed. Open your terminal and run:
This shows your current default Python 3 version. If it still says 3.6, don’t worry!
Step 2: Install Python 3.8 (if not already done)
If you haven’t done this step yet, you can install Python 3.8 by running:
Step 3: Update Alternatives
Now let’s set Python 3.8 as your default. Use the following command:
This tells your system to recognize Python 3.8 as a higher priority than Python 3.6.
Step 4: Choose Your Default Version
Next, you can select which version to use by default:
A prompt will show up. Just enter the number corresponding to Python 3.8 and hit Enter.
Step 5: Verify the Change
Now, check to make sure it worked:
If it shows Python 3.8.x, you’re all set!
Step 6: Install pip for Python 3.8
You might also want to ensure you have pip installed for Python 3.8:
Should You Uninstall Old Versions?
It’s unnecessary to uninstall Python 3.6 unless you are running into specific conflicts. Keeping it means you can always switch back if needed!
Final Tips
sudo
. They can change system settings.~/.bashrc
file if you manually changed paths; it might be easier just to manage versions withupdate-alternatives
.With these steps, you should be good to go with Python 3.8 as your default! Happy coding!
To set Python 3.8 as the default version on your Ubuntu 20.04 system while keeping Python 3.6 intact, you can use the ‘update-alternatives’ command effectively. First, ensure that Python 3.8 is installed correctly by checking with `python3.8 –version`. Next, run the command `sudo update-alternatives –install /usr/bin/python3 python3 /usr/bin/python3.6 1` to set Python 3.6 as the priority 1 version, followed by `sudo update-alternatives –install /usr/bin/python3 python3 /usr/bin/python3.8 2` to set Python 3.8 with priority 2. You can now choose your default version by running `sudo update-alternatives –config python3` and selecting the desired version. Make sure to check that everything is working correctly by executing `python3 –version` afterward.
Regarding pip, you should also install the pip version that corresponds to Python 3.8. You can do this by running `sudo apt install python3.8-distutils` followed by `curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py` and then `python3.8 get-pip.py`. This will install pip for Python 3.8 specifically. It’s advisable not to uninstall Python 3.6 unless you are absolutely certain you won’t need it, as some system utilities may depend on it. Follow these steps carefully, and you should be able to use Python 3.8 without any issues. Avoid modifying the PATH in your .bashrc file unless you’re confident; sticking to the update-alternatives method is safer for beginners.