How To Update Python Mac Terminal



Head to python.org. Click 'Downloads', then download the latest version from there: This downloads the 64-bit version of the latest Python release (3.8.5 as of August 2020). NOTE: If your Mac's OS version is older than 10.9 (year 2013), I recommend upgrading your OS first. If you are unable to, see. 1) Open up Python official download site. It looks something like the image below. Press Download Python 3.7.4 (release date was July 8, 2019) or Download Python 3.8.0 (release date was Oct. 14, 2019) or the version you would like to download. 2) Use the download installer to install Python 3.7. Learn how to uninstall Python on Mac and completely remove its related software components from your MacBook. Complete removal guide. Search for Terminal and open it. If you would like to delete only a specific version of Python, please update your command as below. Removing Python 2.7. Removing Python 3.8. Step 3: Remove Python.

With Python, the best practice of pinning all the packages in an environment at a specific version ensures that the environment can be reproduced months or even years later.

Mac update python from 2 to 3
  • Pinned packages in a requirements.txt file are denoted by . For example, requests2.21.0. Pinned packages should never be updated except for a very good reason, such as to fix a critical bug or vulnerability.
  • Conversely, unpinned packages are typically denoted by >=, which indicates that the package can be replaced by a later version. Unpinned packages are more common in development environments, where the latest version can offer bug fixes, security patches and even new functionality.

As packages age, many of them are likely to have vulnerabilities and bugs logged against them. In order to maintain the security and performance of your application, you’ll need to update these packages to a newer version that fixes the issue.

The pip package manager can be used to update one or more packages system-wide. However, if your deployment is located in a virtual environment, you should use the Pipenv package manager to update all Python packages.

Python Package Upgrade Checklist

Version

In general, you can use the following steps to perform a package upgrade:

1. Check that Python is installed

Before packages can be updated, ensure that a Python installation containing the necessary files needed for updating packages is in place by following the steps outlined in <Installation Requirements>

2. Get a list of all the outdated packages

To generate a list of all outdated packages:

3. Upgrade outdated packages

Depending on your operating system or virtual environment, refer to the following sections.

Update all Python Packages on Windows

The easiest way to update all packages in a Windows environment is to use pip in conjunction with Windows PowerShell:

  1. Open a command shell by typing ‘powershell’ in the Search Box of the Task bar
  2. Enter:

This will upgrade all packages system-wide to the latest version available in the Python Package Index (PyPI).

Update all Python Packages on Linux

Linux provides a number of ways to use pip in order to upgrade Python packages, including grep and awk.

To upgrade all packages using pip with grep on Ubuntu Linux:

To upgrade all packages using pip with awk on Ubuntu Linux:

Updating Python Packages on Windows or Linux

Terminal

Pip can be used to upgrade all packages on either Windows or Linux:

  1. Output a list of installed packages into a requirements file (requirements.txt):
  1. Edit requirements.txt, and replace all ‘’ with ‘>=’. Use the ‘Replace All’ command in the editor.
  2. Upgrade all outdated packages:

Updating all Packages in a Virtual Environment

The easiest way to update unpinned packages (i.e., packages that do not require a specific version) in a virtual environment is to run the following Python script that makes use of pip:

Updating all Packages in a Pipenv Environment

The simplest way to update all the unpinned packages in a specific virtual environment created with pipenv is to do the following steps:

  1. Activate the Pipenv shell that contains the packages to be upgraded:
  1. Upgrade all packages:

Related Quick Reads

Install Python packages and automatically resolve dependencies

ActivePython includes 400+ Popular Python Packages, Pre-Verified.

  • Install Python packages in minutes – pre-built or customize your own
  • Automatically resolves dependencies
  • Code more, build less

Being a software engineer, you often come across many instances where you would require to have Python installed on your Mac.

However, the issue is most modern macOS versions come with rather with Python 2.7.x installed and not the newer, modern version like Python 3.6.5 or Python 3.7.2 (which is the most up-to-date version right now).

This short guide is written to show you how to properly install Python 3 on a Mac OS Xcomputer.

Before you jump into the guide, do take note that there are multiple ways to install Python 3 on a Mac but with this guide, I’ll show you the two easiest ways to do this, step-by-step.

Personally, the way I did it was using a package manager like HomeBrew (it’s okay if you don’t understand what it is). Again, I’ll show you how to do this method down below.

Version
Wait, how do I check if Python 3 is already installed on my Mac?

Simple. Open up your Terminal and type the following line python --version and then hit your Enter key:

You should see the python version that is currently installed on your Mac.

How to Install Python 3 on macOS: 2 Ways

1. The Simplest Way.

Perhaps the simplest way to install Python 3 on macOS.

This is for you especially if you’re a newbie (though I still strongly recommend you try the HomeBrew method below) or if you don’t want to deal with copy-pasting code into your Terminal and downloading other software.

Mac

Here’s how to install Python 3 on your macOS:

  1. Jump into Python.org downloads page and simply just download the latest Python version.
  1. Next, run the Python Installer to install Python 3 onto your Mac.

Note

The Python installation may require about 100MB of disk space to install. Once you’ve installed Python 3 you can have it alongside Python 2 without having to delete the latter from your Mac.

  1. Great! Now once Python 3 is installed, you’ll be able to find it within the Applications directory of your Mac. You’ll also find here a simple IDE called “IDLE.app” which gives you a basic Python IDE.
Help! Where do I find the Applications directory?

If you can’t find the Applications directory, simply go to Finder by clicking the Finder icon in the Dock (it’s usually the first icon from the left side of the Dock). From there simply, go to the Go menu and select Applications.

Done. If you got yourself lost through the process, you can comment down below.

Next up, I’ll show you how you can install Python 3 using HomeBrew onto your macOS. This is my preferred way and it is just as simple as the method before but it will make your life a whole lot simpler, in the long run, using Python.

2. Install Python 3 on Mac using HomeBrew.

How To Update Python Mac Terminal

This method is dead-ass simple and a little fun. 🙂

First of all, you’ll need to have this thing called HomeBrew installed on your Mac. Homebrew is basically a “package manager”. A package manager is an application that helps you install the stuff you need that Apple (or even your Linux System) hadn’t installed in the first place for you.

It’s simple, fast and safe.

Second, you will need to have installed XCode onto your Mac. If you’re thinking of learning how to program or creating iOS apps on your Mac, then it’s good to have XCode installed. We will be using XCode to install HomeBrew application.

Upgrade Python Mac Terminal

Note

If you have already installed XCode onto your Mac you can skip step 1 and jump straight to step 3.

Here are the steps to install XCode, HomeBrew as well as install Python 3 using HomeBrew onto your Mac:

  1. Jump into your Terminal app on your Mac and run the copy/paste the following command into the Terminal to install XCode onto your Mac:
  2. Simply click through all the confirmation crap that XCode shows. It may take a little while to install XCode since it is a large program.
  3. Great! Now that you have XCode installed, you can install HomeBrew! To install HomeBrew, simply copy/paste the following command into your Terminal:

Note

You can confirm the HomeBrew installed correctly by running the command: below:

  1. You’ve installed HomeBrew! Now let’s install the Python 3, the reason why you’re here. To install the latest version of Python, just copy/paste the following command into your Terminal:

Note

You can confirm which version of Python was installed all by running the command below (the exact same command you tried earlier in this guide). It should show up as follows:

  1. Finally, let’s run our new Python 3. Simply enter python3.

Mac Upgrade Python 3

Voila! You have now installed Python 3 successfully if you see something similar in your Terminal:

Bonus

If you want to exit, type exit() and then hit your Return button on your keyboard. You can also hit both Control and D keys at the same time instead of the Return key.

Remember I mentioned you can run both your new Python 3 alongside your old Python 2? Yup. Simply type python into the Terminal to run with Python 2.

How To Update Python Version On Mac Using Terminal

Share this guide with someone who’s looking to install Python 3 on macOS.