How to update python terminal

How to Update Python on Mac Terminal

If you’re a frequent user or developer of Python scripts, you definitely know how powerful it is. You also know the importance of keeping your Mac updated with the latest version so that you can take advantage of everything it has to offer.

Most of us who use and create Python scripts spend a great deal of our time in Mac Terminal so it only makes sense that you would want to be able to update your version of Python from the Terminal application. It’s easy to do and I will show you how to do it here.

Читайте также:  Python psutil запущенные процессы

My name is Eric and I have been a Software Engineer and Configuration Manager for over 20 years. Deploying and installing new versions of software is a key function in my job and updating Python is fairly straightforward and something anyone can do.

Follow me through this article if you would like to learn how to update Python from Mac Terminal. We will also cover how to update it from your desktop. Once you learn, you can easily keep your version of Python up to date.

So keep reading to get started!

How to Update Python on Mac with Homebrew

The easiest way to update Python using Mac Terminal is with Homebrew. Follow the steps below to ensure you keep your version of Python up to date.

Step 1: Open Mac Terminal

You can open Mac Terminal either from your dock or Launchpad. By default, it is nested in the “Other” folder in Launchpad.

Step 2: Install Homebrew

If you already have Homebrew installed, you can skip to the next step. If you have never installed it on your Mac then you will need to install it. Run the command below to install Homebrew. Note: the command shown is all one line.

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”

You’ll be asked for your admin account password. This should be the password you use to log in to your Mac. Then you will see lots of output on the screen.

Keep an eye on the screen as you may need to hit Return/Enter to continue and possibly enter your password again. The entire installation will take a few minutes.

Step 3: Install the Latest Version of Python

In the Terminal application, type the command below to install the latest version of Python.

brew install Python

Once completed the latest version of Python will be installed.

Step 4: Invoke the New Version with the python3 Command

The latest version of Python is installed as python3. To use the new version you will want to use the command python3.

The old version of Python that came with your Mac will still be there and can be used with the original python command. There are ways to change this but I would recommend leaving it because there are instances where your macOS may need the original version.

How to Update Python on Mac using Python Installer

If you’re not comfortable installing Python from Mac Terminal using the commands shown above, you can install it from your desktop using the Python installer. The steps below will show you how to do this.

Step 1: Open your Browser from the Mac Desktop

Open your favorite internet browser before moving on to step 2.

Step 2: Download the Installer from Python.org

Once you get to Python.org, click on the Downloads menu. It will automatically detect your macOS and provide you with a button to download the latest version.

Step 3: Double-Click on the Python Install Package to Begin Installation

The installer will startup. Click on the continue button.

Step 4: Follow the On-Screen Instructions

After clicking “Continue,” you will need to follow the on-screen instructions. It will step you through the license agreement, and give you options as to where to install it and the type of installation. You can accept all the default options or change them if you would like to do so.

Step 5: Open IDLE to Verify it was Installed Correctly

Once the installation completes, open the IDLE applications to verify the version and that it works.

How to Determine the Python Version on Your Mac

If you want to see your current version of Python, you can do so by typing python or python3 with the –version parameter as shown below. Remember to run the version of Python that you are looking for (python or python3).

python –version

python3 –version

Once the command is run, you will see an output showing the current version.

Conclusion

Updating Python on your Mac is fairly simple and can be done by anyone. It can be done using Mac Terminal or through the desktop installation as we have seen above. Both methods work well so use the one you are most comfortable with.

As usual, let me know if you have any questions or comments. I would love to hear from you!

Leave a Reply Cancel Reply

Kisha

But you installed version 3.10.4 but when you check the version in the terminal you still get older versions.
Why? Reply

Eric

Hi Kisha,
Good catch noticing that. The version check is just a general command that I wanted to show how to do and in the case shown above, I had done the version check and taken the screenshot right after I installed Python from the command line in the earlier section. If I run the command now after I installed the desktop version, I can see that it has the same version. I tried putting a screenshot here but it won’t let me. I hope that makes sense. It’s just a matter of when I ran the command and took the screenshot. Thanks for the observation and question. I appreciate it. Reply

Источник

How to Update Python in Windows, Linux & MacOS

Every year Python launches a new version of itself to provide new and improved services to its users. With every update, Python launches new features and bug fixes. This article shows, How to update Python on different platforms?

A section of the article also shows how to check the current Python version installed in the system.

Check your Python version:

Before updating Python, one should check if one already has the latest version of Python in the system. Let us now follow the steps provided in the subsequent section for fetching the Python version.

For Windows

Open the command prompt to check the Python version installed:

  1. Click the Windows key and search cmd.
  2. Open the command prompt, type python, and hit enter.

Its version number shall appear after the phrase Python.

For MAC

Python comes pre-installed in the MAC operating system. If your computer has an old Python version, programmers can update it to the latest one following the process given here.

For checking the Python version present in the system:

  1. Open the application folder ->Utilities folder->open the terminal.
  2. Once you open the terminal window, type the given command, and click the return key to confirm the version of Python.

The above command shall show the Python’s version number that is installed in your computer.

For Linux

Python comes pre-installed in the Linux operating system. Before updating, it is crucial to check the Python version installed in the system.

To check the Python version present in the system:

  1. Open the terminal window in Linux by simply clicking Ctrl + Alt + T
  2. Type the below command and hit the return key

This command will display the current Python version number installed in the system.

Updating the Python for various platforms (MAC, Windows, and Linux)

One can update Python by going to its official site and then downloading the latest version of Python available. One can also use the terminal or command prompt of the operating system to update Python.

Update Python in Windows

Updating Python is easy for Windows users.

  1. Go to the website of Python, and click on the Python download button
  2. After clicking the Python download button, downloading of the installation file shall begin
  3. Now run the installer, the installer will automatically suggest downloading the latest version of Python
  4. And, if the system has an old Python version, the installer will display an upgrade now button. Click the button to start the upgrading process.

Update Python in MAC Systems

One can update Python for MAC from Python’s official website. One can also update Python in MAC using Homebrew. You have to follow the steps provided in the subsequent section to update Python with Homebrew:

First, one needs to have the Homebrew package manager in his system. To do that, one must download Homebrew from the Homebrew site. One can also download Homebrew by copying the below code into the terminal.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Now to update Python, enter the below commands in the terminal:

brew upgrade python3 #(old Python version number)

Update Python in Linux Systems

If the system doesn’t have the latest version of Python, one can update the Python by copying the below commands to the terminal:

sudo apt update sudo apt install software-properties-common

The above command will install all the essential packages required to install the latest version of Python.

Every year Python launches a new version to provide new and improved services to its users. This article is about installing the latest and updated Python’s version. One can follow the above steps to check if Python’s latest version is already present in the system. Knowing that will surely save a lot of time and effort.

  • Python Online Compiler
  • Addition of two numbers in Python
  • TypeError: ‘int’ object is not subscriptable
  • Armstrong Number in Python
  • Python Uppercase
  • Top Online Python Compiler
  • Polymorphism in Python
  • Inheritance in Python
  • Python String Contains
  • Python eval
  • Python Range
  • Python IDE
  • Install Opencv Python PIP Windows
  • Reverse Words in a String Python
  • Ord Function in Python
  • Only Size-1 Arrays Can be Converted to Python Scalars
  • Python slice() function
  • indentationerror: unindent does not match any outer indentation level in Python
  • Python Infinity
  • Python Return Outside Function

Источник

How to update python terminal

In order to update python version on the terminal, you can use these commands depending on your operating system:

1#Linux 2 sudo apt update 3 sudo apt install python3.11 4 5 #MacOS 6brew install python

Here is a detailed guide about how to update python version in other operating systems. In this article, we are going to focus on how to install it on the terminal.

Update Python on Windows

To update Python on Windows you should download the Python version you want to upgrade to from python.org. In case you already have installed different Python versions and want to update the version of a virtual environment, you can do it by using the following command:

1python -m venv --upgrade VIRTUAL-ENVIRONMENT-PATH-HERE

To select which Python version we want to use, it’s as simple as as writing py -version-you-want-to-use , example:

1 py -3.8 #selects Python version 3.8 2 py -3.11 # Selects Python version 3.11

Updating Python on Linux

Before getting into upgrading Python, we need to know if it’s already installed (no use to upgrade something that doesn’t exist). To check if Python is installed type the following:

If there’s an installed version of Python, the output should show you the installed version like this:

If your computer doesn’t have Python installed, we need first to prepare our system to install Python, so we do the following:

1sudo apt update 2 sudo apt install software-properties-common

Once we have downloaded the necessary files to install Python latest version, we can install it using apt-get (recommended) or using the source code.

Update with Apt-Get

There’s no need to reinvent the wheel, Apt-Get it’s a package manager built in Linux that will make our life easier while installing. As a first step, let’s configure the deadsnakes PPA on the system by running the following command:

1sudo add-apt-repository ppa:deadsnakes/ppa
1sudo apt update 2 sudo apt install python3.9

Python is now updated, but still is pointing to the previously installed version. We need now to update this:

1 sudo update-alternatives --config python3

A list of options will be displayed and prompt to pick the Python version you want to point to, select it by writing the number corresponding to the version you want to use. To verify this selection, write:

Updating Python on MacOs

Updating Python on MacOs is more straight forward. In MacOs systems you can as well have different Python versions installed at the same time. This makes it simpler to update it by visiting python.org MacOs download page, select the installer to download and run it. If you are more of a Homebrew user, run the following commands:

Once the installation finishes, you’ll have the latest Python version installed which you can verify with the following code:

Источник

Оцените статью