Catalina Python3

  • How to set python version to python3,i have install python3. Cclauss changed the title Python version for MAC catalina Python version for macOS Catalina May 11, 2021.
  • Python has been installed as $(brew -prefix)/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. Pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into.
Catalina

Python has made life extremely easy for developers and data scientists, at least most of the time. One exception that ruins their life is dealing with Python versions. There would sometimes be lots of Pythons existing on a Mac at the same time. Where are they from? Are they provided by Apple? Which one am I using? Where did the packages I installed go? This article would give some insights into those questions. This article is NOT for beginners and DO NOT teach you how to install Python. It aims to give you a better understanding of all the Python interpreters you may have on your Mac.

Python 3.7.11 June 28, 2021 Download Release Notes; Python 3.6.14 June 28, 2021 Download Release Notes; Python 3.9.5 May 3, 2021 Download Release Notes; Python 3.8.10 May 3, 2021 Download Release Notes; Python 3.9.4 April 4, 2021 Download Release Notes; Python 3.8.9 April 2, 2021 Download Release Notes; Python 3.9.2 Feb. 19, 2021 Download. Python 3.7.8 was the last bugfix release of Python 3.7 before 3.7 entered the security-fix phase of its life cycle. We plan to provide security fixes until mid 2023, five years after its initial release. Note that there are updated binary installers available for 3.7.9. Binary installers are normally not provided for security fix releases.

Catalina Python 3 Download

Sure, Python is undoubtedly a programming language, but it is not only a programming language. The name 'Python' frequently used in this article would refer to the Python interpreter program most of the time. Unlike C language, which is compiled to machine code and executed by the processor directly, Python is not compiled but interpreted. It means when your Python program is running, there needs to be another program running at the same time, interpreting every line of your Python code to your processor, and the program is THE Python we are talking about in this article.

Catalina Python3 Pip

More specifically, this title means 'Which python interpreter program am I using to run my Python program?'. Most of the time, you use one of the interpreter programs with the command python or python3. However, it's good to know how many interpreters you have and which one you are currently using with the python command. Here are some ways that help you to find out which python you are using.

The type command

type command tells you how your shell resolves a command, in this case, the command python or python3. It gives the path to the program that is directly involved with a command. In my system, you would see the following outputs.

Take python as an example. It tells you /usr/bin/python is called when you use the command python. However, the path is not necessarily your interpreter's real path: it may be an alias or a trampoline. To see the actual path of the interpreter, you need other commands.

The sys.executable variable

sys.executable gives the absolute path of the executable binary for the Python interpreter you're currently using.

Python3

Catalina Python 3d

The sys.path variable

It's common for beginners to install the wrong interpreter package and ends up being unable to import the desired package. sys.path is a list of strings that specifies the search path for modules, and it tells where the packages you installed (typically with pip) go.

As far as I know, there is currently not an efficient way to find all Python interpreter programs that now exist on your Mac. However, I could still give the common interpreter paths you may expect on your Mac. If you come to find a way to list all interpreters or find a new Python interpreter path that is not mentioned, you are more than welcomed to share it with me.

Catalina Python3

Built-in Interpreters

Even if you don't install Python explicitly, there may be more than one Python interpreter available on your Mac already. It is not wise to remove or modify these interpreters, and you can only install packages with pip command for the user, not globally. Python you found under /usr/bin is usually system built-in interpreters, files under this path cannot be modified by users without modifying SIP, and it is strongly suggested not to do so. As far as I know, there may be 3 interpreters that are provided by the system.

  • /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7: the Python 2.7 interpreter. Almost all Macs have this interpreter, its alias is located in /usr/bin/python
  • /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7: the Python 3.7 interpreter. From macOS Catalina (reference here), the system gives this interpreter and prompts a deprecation warning when you use the system Python 2.7. It's by default /usr/bin/python3.
  • /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8: a Python interpreter installed by Xcode somehow. As far as I've observed, it overwrites /usr/bin/python3, after that, deleting the Xcode app cause /usr/bin/python3 malfunctions.

User Installed Interpreters

As the built-in interpreters may serve some system functionalities, I prefer to install another interpreter to separate my stuff from the system's interpreter. To install a Python interpreter, you can use Homebrew or install it from python.org. Here are the possible locations of the Python interpreter installed by the user.

  • /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7: the Python interpreter I installed from python.org. One of its aliases is located at /usr/local/bin/python3, and it is what my python3 command refers to.

Posted on October 4, 2016 by Paul

Updated 15 June 2021

In this article, I will show you how to install Python with NumPy, SciPy and Matplotlib on macOS Big Sur.

I assume you are on an Intel based Mac. If you have an arm64 Mac, also called Apple Silicon, please check my other article.

MacOS Big Sur comes by default with Python 2.7 which, at this point, receives only bug fixes and is EOL since 2020. Python 3 is the future and it is supported by all major Python libraries. In this tutorial, we’ll use Python 3.9 which is the latest stable release of Python at the time of this writing.

Start by installing the Command Line Tools for macOS. Please note, that you will need the Command Line Tools even if you’ve already installed Xcode. Open a Terminal and write:

Once the Command Line Tools are installed, we can install Python.

As a side note, after you install the Command Line Tools, you will also get a slightly older Python 3 version (3.8). In this article, we are going to use the latest stable version of Python which, at the time of this writing is 3.9.

Go to https://www.python.org/ and download Python. The official installer of Python is a pkg file that will start a GUI installer which will guide you through the installation.

You can have multiple Python 3 versions installed on your macOS machine. If this is the case, you can select which version you want to use by specifying the version number, e.g.:

or:

After the above, you can invoke Python 3.9 using the python3.9 command. python3 will also invoke the latest installer version of Python 3. This is what I see if I run python3.9 on my machine:

Next, let’s follow best practices and create a new Python environment, named work (feel free to use a different name), in which we can install NumPy, SciPy and Matplotlib:

At this point, your prompt should indicate that you are using the work environment. You can read more about Python environments in the documentation.

Once an environment is activated, all the install commands will apply only to the current environment. By default, if you close your Terminal, the environment is deactivated. If you want to be able to use it, use the source work/bin/activate command.

We can install NumPy, SciPy and Matplotlib with:

As a side note, when you are in an active environment you can use the python command to invoke the Python interpreter, no need to use the version number.

Catalina Python3 Install

Fire up Python, import scipy and print the version of the installed library. This is what I see on my machine:

Let’s try something a bit more interesting now, let’s plot a simple function with Matplotlib. First, we’ll import NumPy and Matplotlib with:

Next, we can define some points on the (0, 1) interval with:

Mac Catalina Python3 Default

Python3

Now, let’s plot a parabola defined on the above interval:

You should see something like this:

As you’ve probably noticed, plt.show() is a blocking command. You won’t be able to use the interpreter until you close Figure 1.

There is also an interactive mode in which you can plot functions. Close Figure 1 and write:

This is what you should see:

Catalina Python3 Default

At any point you can disable the interactive plot mode with:

after which you will need to use the plt.show() function in order to actually see the result of the plt.plot function.

If you want to learn more about Python and Matplotlib, I recommend reading Python Crash Course by Eric Matthes. The book is intended for beginners, but has a nice Data Visualization intro to Matplotlib chapter:

Another good Python book, for more advanced users, which also uses Matplotlib for some of the book projects is Python Playground by Mahesh Venkitachalam:


Show Comments