Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

askthedev.com Logo askthedev.com Logo
Sign InSign Up

askthedev.com

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Ubuntu
  • Python
  • JavaScript
  • Linux
  • Git
  • Windows
  • HTML
  • SQL
  • AWS
  • Docker
  • Kubernetes
Home/ Questions/Q 10758
Next
In Process

askthedev.com Latest Questions

Asked: September 26, 20242024-09-26T11:06:00+05:30 2024-09-26T11:06:00+05:30In: Python, Ubuntu

What steps should I follow to set Python 3.8 as the default version used in Ubuntu 20.04?

anonymous user

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!

  • 0
  • 0
  • 2 2 Answers
  • 0 Followers
  • 0
Share
  • Facebook

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here
    Continue with Google

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. anonymous user
      2024-09-26T11:06:01+05:30Added an answer on September 26, 2024 at 11:06 am



      How to Set Python 3.8 as Default on Ubuntu 20.04

      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:

      python3 --version

      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:

      sudo apt update
      sudo apt install python3.8

      Step 3: Update Alternatives

      Now let’s set Python 3.8 as your default. Use the following command:

      sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
      sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

      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:

      sudo update-alternatives --config python3

      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:

      python3 --version

      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:

      sudo apt install python3.8-distutils
      wget https://bootstrap.pypa.io/get-pip.py
      python3.8 get-pip.py

      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

      • Be careful while running commands with sudo. They can change system settings.
      • If you ever mess up, you can always reinstall Python.
      • Check your ~/.bashrc file if you manually changed paths; it might be easier just to manage versions with update-alternatives.

      With these steps, you should be good to go with Python 3.8 as your default! Happy coding!


        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. anonymous user
      2024-09-26T11:06:01+05:30Added an answer on September 26, 2024 at 11:06 am


      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.


        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Related Questions

    • I'm having trouble installing the NVIDIA Quadro M2000M driver on Ubuntu 24.04.1 LTS with the current kernel. Can anyone provide guidance or solutions to this issue?
    • What steps can I take to troubleshoot high usage of GNOME Shell in Ubuntu 24.04?
    • I recently performed a fresh installation of Ubuntu 24.04, and I've noticed that my RAM usage steadily increases over time until my system becomes unresponsive. Has anyone experienced this issue ...
    • How can I resolve the "unknown filesystem" error that leads me to the GRUB rescue prompt on my Ubuntu system?
    • I'm experiencing an issue with Ubuntu 24.04 where Nautilus fails to display the progress indicator when I'm copying large files or folders. Has anyone else encountered this problem, and what ...

    Sidebar

    Related Questions

    • I'm having trouble installing the NVIDIA Quadro M2000M driver on Ubuntu 24.04.1 LTS with the current kernel. Can anyone provide guidance or solutions to this ...

    • What steps can I take to troubleshoot high usage of GNOME Shell in Ubuntu 24.04?

    • I recently performed a fresh installation of Ubuntu 24.04, and I've noticed that my RAM usage steadily increases over time until my system becomes unresponsive. ...

    • How can I resolve the "unknown filesystem" error that leads me to the GRUB rescue prompt on my Ubuntu system?

    • I'm experiencing an issue with Ubuntu 24.04 where Nautilus fails to display the progress indicator when I'm copying large files or folders. Has anyone else ...

    • How can I configure a server running Ubuntu to bind specific IP addresses to two different network interfaces? I'm looking for guidance on how to ...

    • Is it possible to configure automatic login on Ubuntu MATE 24.04?

    • After upgrading from Ubuntu Studio 22.04 to 24.04.1, I lost all audio functionality. What steps can I take to diagnose and resolve this issue?

    • I am experiencing issues booting Ubuntu 22.04 LTS from a live USB. Despite following the usual procedures, the system fails to start. What steps can ...

    • I'm encountering a problem with my Expandrive key while trying to update my Ubuntu system. Has anyone else faced similar issues, and if so, what ...

    Recent Answers

    1. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    2. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    3. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    4. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    5. anonymous user on How can I update the server about my hotbar changes in a FabricMC mod?
    • Home
    • Learn Something
    • Ask a Question
    • Answer Unanswered Questions
    • Privacy Policy
    • Terms & Conditions

    © askthedev ❤️ All Rights Reserved

    Explore

    • Ubuntu
    • Python
    • JavaScript
    • Linux
    • Git
    • Windows
    • HTML
    • SQL
    • AWS
    • Docker
    • Kubernetes

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.