Unable to set default python version to python3 in ubuntu

Matheus Mello
Matheus Mello
September 2, 2023
Cover Image for Unable to set default python version to python3 in ubuntu

📝🐍💻 Introducing the Ultimate Guide to Setting Default Python Version to Python 3 in Ubuntu! 🚀🔥

Are you an Ubuntu user struggling to set the default Python version to Python 3? 😓 Don't worry, you're not alone! Many developers face this common issue, and we're here to help you conquer it with ease! 💪👊

In Ubuntu 16.04, the default Python version is Python 2.7, but if you prefer to use Python 3 as your default version, follow these simple steps. Let's dive in! 🏊‍♂️💻

  1. Open your terminal and enter the following command:

    update-alternatives --remove python /usr/bin/python2

This command removes the link to the Python 2 executable, allowing us to set Python 3 as the default version. However, the real magic happens in the next step! ✨

  1. Now, execute the following command:

    update-alternatives --install /usr/bin/python python /usr/bin/python3 1

🔍 Ah, but hold on! If you receive the following error message:

update-alternatives: --install needs <link> <name> <path> <priority>
Use 'update-alternatives --help' for program usage information.

Do not fret! It means you forgot to include the priority level (in this case, we set it as 1). 🙃

To fix this, simply modify the command and include the priority level like this:

update-alternatives --install /usr/bin/python python /usr/bin/python3 <priority>

Replace <priority> with a number higher than the priority level of any other alternative Python version listed in the output of the next command we're going to run. 😉

  1. Lastly, execute this command to configure Python 3 as your default Python version:

    sudo update-alternatives --config python

This command allows you to choose the default Python version interactively. You'll be presented with a list of available Python versions, including the one we just installed. Simply type the corresponding number and hit Enter! 🎉

Boom! You did it! 🎆✨ Now, your default Python version will be set to Python 3, and you'll be able to enjoy all the amazing features and enhancements it offers. 🐍💕

Remember, setting the default Python version to Python 3 is crucial for compatibility and taking advantage of the latest packages and improvements. So why wait? Jump right in and make the switch today! ⚡🔛

If you encountered any issues or have questions, feel free to reach out to us or leave a comment! We're here to support you on your coding journey! 🤝💬✉️

Start coding with Python 3 in Ubuntu and unleash your full programming potential! Happy coding! 😄💻🚀

Keep exploring, keep learning, and keep pushing those code boundaries! 📚🔍🌟

Now, it's your turn to share! If you found this guide helpful, spread the knowledge by sharing it with your fellow developers and friends. Together, we can empower the coding community! 🌐💌

#Python3 #Ubuntu #Tutorial #Tech #CodingTips

Take Your Tech Career to the Next Level

Our application tracking tool helps you manage your job search effectively. Stay organized, track your progress, and land your dream tech job faster.

Your Product
Product promotion

Share this article

More Articles You Might Like

Latest Articles

Cover Image for How can I echo a newline in a batch file?
batch-filenewlinewindows

How can I echo a newline in a batch file?

Published on March 20, 2060

🔥 💻 🆒 Title: "Getting a Fresh Start: How to Echo a Newline in a Batch File" Introduction: Hey there, tech enthusiasts! Have you ever found yourself in a sticky situation with your batch file output? We've got your back! In this exciting blog post, we

Cover Image for How do I run Redis on Windows?
rediswindows

How do I run Redis on Windows?

Published on March 19, 2060

# Running Redis on Windows: Easy Solutions for Redis Enthusiasts! 🚀 Redis is a powerful and popular in-memory data structure store that offers blazing-fast performance and versatility. However, if you're a Windows user, you might have stumbled upon the c

Cover Image for Best way to strip punctuation from a string
punctuationpythonstring

Best way to strip punctuation from a string

Published on November 1, 2057

# The Art of Stripping Punctuation: Simplifying Your Strings 💥✂️ Are you tired of dealing with pesky punctuation marks that cause chaos in your strings? Have no fear, for we have a solution that will strip those buggers away and leave your texts clean an

Cover Image for Purge or recreate a Ruby on Rails database
rakeruby-on-railsruby-on-rails-3

Purge or recreate a Ruby on Rails database

Published on November 27, 2032

# Purge or Recreate a Ruby on Rails Database: A Simple Guide 🚀 So, you have a Ruby on Rails database that's full of data, and you're now considering deleting everything and starting from scratch. Should you purge the database or recreate it? 🤔 Well, my