Return to site

How To Update Python Mac Terminal

broken image


Both python 2x and 3x can stay installed in a MAC. Mac comes with python 2x version. To check the default python version in your MAC, open the terminal and type-python -version However to check, if you have already installed any of python 3x versions, you need to type. Python3 -version If you don't then go ahead and install it with the installer. The official home of the Python Programming Language. While Javascript is not essential for this website, your interaction with the content will be limited.

Pip is a popular command used to manage Python packages. Pip command is also used for updating/upgrading already installed Python packages.

MacOS or Linux: Open the terminal window. Now, type the following command to update the latest anaconda version. Conda update conda. If you want to update the specific version, then you can use the following command. Conda update anaconda=VersionNumber The command conda update anaconda=VersionNumber grabs the specific release of the Anaconda. Here are different methods to Update Python on your Mac. One can install Python without using the terminal on MacBook Air or Mac. For this, you need to download the Python installer from the python.org website. Follow the steps below: Visit Python.org and download the latest available Python 3 installer file. Run the downloaded file and install. By default MacOS ships with Python-2. But, I guess most of us have long back started to work with Python-3 and it is very irritating to run python3 every time instead of python in terminal.

List Installed Python Packages

Before updating or upgrading an installed Python package we will list already installed packages. We will use the list command which will display the complete name and the version of the installed packages.

Check If A Python Package Is Installed

In the previous example, we have just listed all installed packages and versions. We can also check if a specific python package is already installed. We will also use grep command by providing the name of the package we want to check.

List Outdated Python Packages

Pip command also provides --outdated options with the list command which will list outdated and already installed python packages.

Upgrade/Update Python Package To The Latest Version

We will use the install command with the --upgrade option and also provide the package name. In this example, we will update/upgrade the package named Django to the latest version. We will also provide the --user option. Alternatively to the --upgrade we can use -U which is the short form.

From the screenshot, we see that first the Django version 2.0 is found. Django version 2.0 is uninstalled and then Django version 2.2.5 is installed which will complete the upgrade/update of the Django.

Upgrade/Update Python Package To The Specific Version

In the previous example, we have updated the Django python package to the latest version. We can also update/upgrade a python package into a specific version which is not the latest. In this example, we will upgrade/update a specific version which is not the latest with the equal signs. We will not use the --upgrade option but specify the upgraded version.

We can see that the currently installed version is Django 2.0 but we will upgrade it into version 2.2 .

Downgrade Python Package To The Specific Version

We can also downgrade the installed package into a specific version. We will specify the Python package name with the version we want to downgrade by using equation signs like below. In this example, we will downgrade the Django package to version 2.0.

Python is a versatile language used for multi-purpose programming it is undoubtedly the most popular dynamic programming language that is being used today.

How To Update Python Mac Terminal

Python is an open source object-oriented programming language made by Dutchman Guido van rossum in 1991.

Python is an excellent choice for beginners and experienced developers, Python 3 is the most current version of the language and is considered to be the future of Python.

Python 2.X comes preinstalled on Mac.

You can verify it by running python --version in your terminal; you should get a similar output

How To Install Python Mac Terminal

But if you check for Python 3 by running python3 --version you will get an error unless you already have Python 3 installed.

If you are wondering why you should install Python 3 read The key difference between Python 2 and Python 3

How To Update Python Mac Terminal

There are various ways to install Python 3, including a download from the official Python site. However, I strongly recommend instead use a package manager like Homebrew to manage all your packages. It will save you from a lot of headaches.

This tutorial will guide you through installing Python 3 on your local macOS machine and setting up a programming environment via the command line.

Upgrade Python Version On Mac

How to install Python 3 in Mac

Before preceding a quick Note – We'll be completing most of our installation and set up on the command
line, which is a non-graphical way to interact with your computer.

Step – 1

Open your terminal, you can find it by going into Finder, navigating to the Applications folder, and then into the Utilities folder. Alternatively, you can use Spotlight by holding down the command and spacebar keys to find Terminal by typing it out in the box.

Step – 2

Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS. You may have Xcode installed already on your system. To check, in your Terminal window, execute this command – xcode-select -p How to make indent in excel.

If you receive the following output, then Xcode is installed:

/Library/Developer/CommandLineTools

If you get an error then you need to install Xcode first, you can simply install it from the App store Install Xcode

Once Xcode is installed, return to your Terminal window. Next, you'll need to install Xcode's separate Command Line Tools app, which you can do by executing the following command.

Click through all the confirmation commands this may take a while.

Once Xcode and its Command Line Tools app are fully installed, and we are ready to install the package manager Homebrew.

Step -3

In this step, we will install Homebrew which is a package manager. A package manager is a collection of software tools that work to automate installation processes that include initial software installation, upgrading and configuring of software, and removing software as needed.

To install Homebrew run the following command in your terminal –

Homebrew installs packages to their own directory and then symlinks their files into /usr/local.

To confirm the Homebrew installation run this command

Otherwise, you may get a warning to run another command such as brew update to ensure that your installation of Homebrew is up to date.

Once Homebrew is ready, you can proceed further to install Python 3.

Step – 4

Finally, now you can install the latest version of Python by running

The Terminal window will give you feedback regarding the installation process of Python 3. Along with Python 3, Homebrew will install some essential tools such as pip, setuptools, and wheel.

Pip is a valuable tool used to install and manage Python packages. You will use it a lot in your projects.

To verify Python 3 installation, you can run the following

Your version might slightly vary, but as long as it's Python 3 the installation was successful.

To open a Python 3 shell from the command line type python3:

To exit the shell simple type exit() and hit enter.

How To Update Python Mac Terminal

Python is an open source object-oriented programming language made by Dutchman Guido van rossum in 1991.

Python is an excellent choice for beginners and experienced developers, Python 3 is the most current version of the language and is considered to be the future of Python.

Python 2.X comes preinstalled on Mac.

You can verify it by running python --version in your terminal; you should get a similar output

How To Install Python Mac Terminal

But if you check for Python 3 by running python3 --version you will get an error unless you already have Python 3 installed.

If you are wondering why you should install Python 3 read The key difference between Python 2 and Python 3

There are various ways to install Python 3, including a download from the official Python site. However, I strongly recommend instead use a package manager like Homebrew to manage all your packages. It will save you from a lot of headaches.

This tutorial will guide you through installing Python 3 on your local macOS machine and setting up a programming environment via the command line.

Upgrade Python Version On Mac

How to install Python 3 in Mac

Before preceding a quick Note – We'll be completing most of our installation and set up on the command
line, which is a non-graphical way to interact with your computer.

Step – 1

Open your terminal, you can find it by going into Finder, navigating to the Applications folder, and then into the Utilities folder. Alternatively, you can use Spotlight by holding down the command and spacebar keys to find Terminal by typing it out in the box.

Step – 2

Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS. You may have Xcode installed already on your system. To check, in your Terminal window, execute this command – xcode-select -p How to make indent in excel.

If you receive the following output, then Xcode is installed:

/Library/Developer/CommandLineTools

If you get an error then you need to install Xcode first, you can simply install it from the App store Install Xcode

Once Xcode is installed, return to your Terminal window. Next, you'll need to install Xcode's separate Command Line Tools app, which you can do by executing the following command.

Click through all the confirmation commands this may take a while.

Once Xcode and its Command Line Tools app are fully installed, and we are ready to install the package manager Homebrew.

Step -3

In this step, we will install Homebrew which is a package manager. A package manager is a collection of software tools that work to automate installation processes that include initial software installation, upgrading and configuring of software, and removing software as needed.

To install Homebrew run the following command in your terminal –

Homebrew installs packages to their own directory and then symlinks their files into /usr/local.

To confirm the Homebrew installation run this command

Otherwise, you may get a warning to run another command such as brew update to ensure that your installation of Homebrew is up to date.

Once Homebrew is ready, you can proceed further to install Python 3.

Step – 4

Finally, now you can install the latest version of Python by running

The Terminal window will give you feedback regarding the installation process of Python 3. Along with Python 3, Homebrew will install some essential tools such as pip, setuptools, and wheel.

Pip is a valuable tool used to install and manage Python packages. You will use it a lot in your projects.

To verify Python 3 installation, you can run the following

Your version might slightly vary, but as long as it's Python 3 the installation was successful.

To open a Python 3 shell from the command line type python3:

To exit the shell simple type exit() and hit enter.

Note you can still run Python shells with Python 2 by executing python:

How To Update Python Mac Terminal

As the installation is complete go ahead and run your first Python program by following this guide – How to run 'Hello, World!' program in Python 3

How to update Python3?

If in future Python team publishes a new update you can update your Python 3 from the terminal by doing the following.

This will update your Homebrew first followed by Python 3.

How to Create a Virtual Environment in Mac os?

If you have been Following this guide, Now you have Python 2 and Python 3 installed in your Mac.

Unfortunately, there is a lot of contrast between these two versions, Python 3 was introduced to eliminate all the design flaws of the previous version. It brought a lot of changes you can read about them here

So the problem is almost every time, Programs written of Python 2 won't work on Python 3 environment. And Python 2 package Might create a conflict in Python 3 program.

To prevent such situations, it is always recommended to create virtual environments to run Python 2.7 for one project and Python 3.7 for another on the same computer, follow this guide to learn how to create Virtual environments on Mac.





broken image