Unable to set default python version to python3 in ubuntu

Cover Image for Unable to set default python version to python3 in ubuntu
Matheus Mello
Matheus Mello
published a few days ago. updated a few hours ago

📝🐍💻 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


More Stories

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

How can I echo a newline in a batch file?

updated a few hours ago
batch-filenewlinewindows

🔥 💻 🆒 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

Matheus Mello
Matheus Mello
Cover Image for How do I run Redis on Windows?

How do I run Redis on Windows?

updated a few hours ago
rediswindows

# 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

Matheus Mello
Matheus Mello
Cover Image for Best way to strip punctuation from a string

Best way to strip punctuation from a string

updated a few hours ago
punctuationpythonstring

# 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

Matheus Mello
Matheus Mello
Cover Image for Purge or recreate a Ruby on Rails database

Purge or recreate a Ruby on Rails database

updated a few hours ago
rakeruby-on-railsruby-on-rails-3

# 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

Matheus Mello
Matheus Mello