Python is one of the most flexible programming languages you can use for different computer science projects. Installing Python on your Apple silicon Mac is the initial step in writing and running Python code. So if you are new to the Python programming environment or just bought the Apple silicon Mac, how do you get started with Python?
How do you install or update the Python programming language on your new computer?
Read on to find out.
How to Install Python on Apple Silicon Mac?
Your Mac initially ships with Python 2.7, but that is an outdated version. But currently, Python 3.x is the standard throughout the entire Python community (the current version as of writing this is 3.10.0). Also, Python 4.x is on the pipeline and will be launching soon.
In the search option, type terminal, open to find out what version of Python is pre-installed on your computer. If you execute "Python --version" in the terminal after it has loaded, Python version 2.7 should appear.
Last login: sat July 9 18:23:11
Piter@mbp21-19 ~ % python –version
#Output
python 2.7.18
Piter@mbp21-19 ~ %
Even though Python 2.7 is an outdated version, your operating system will stop functioning if you try to delete or uninstall it. This is because macOS Monterey requires Python 2.7, which is dependent on a few programs on your Mac.
So, the question of how to install your own Python installation on your Apple silicon Mac should be your goal. It is crucial to note that, depending on the project you need to work on, you may want to install several Python versions.
There are several ways to install Python 3 on Apple silicon. Let's look at a few of them.
1. Installing Python With Homebrew
If you install Homebrew on Apple Silicon , you will have Python installed automatically. But if you are yet to install Homebrew, open your terminal by pressing (command + space)
, then enter the following.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Your terminal will request access at the Super user level. This requires you to enter your password you use to access your Mac and hit enter. You will be prompted by Homebrew to confirm your desire to install the following. To proceed, hit enter
.
Again, you can install Python on your Apple silicon Mac using Anaconda or Mini-Conda. Let's also see how you can install Python with Mini-Conda.
2. Installing Python in Apple silicon With MiniConda
A collection of numerous open-source packages available in an environment manager is known as Anaconda. Therefore, you can just use Mini-Conda if you don't want the entire package.
This is x64 compatible. If you set up either Mini-Conda or Anaconda, they will function under Rosetta, which functions reasonably well despite being slower. If you wish to run natively on the ARM architecture, you can utilize a different project on the Anaconda page, which is known as Conda Forge.
Download the Conda Forge/Mini Forge from the Miniforge download page. Don't forget to select your operating system and system architecture.
When you launch your terminal after downloading the shell script, type sh
and drag the script file into the terminal window, you should see the path of the file show up in the terminal window then hit enter. a command will ask you whether you want the conda environment to run automatically each time you start the shell or not. But to utilize it, enter "conda activate [name of environment]" followed by the name of your environment.
conda activate kunsha
This will launch you into your new environment, and to check the version of Python installed, enter the following command.
python –version
#Output
Python 3.10.0
(kunsha) Piter@mbp21-19 ~ %
So let's say you wanted to have something other than 3.10.0, maybe 3.8;
conda install python=3.8
After installing the python version, check the version to be certain the installation was successful.
python –version
#Output
Python 3.8.12
(kunsha) Piter@mbp21-19 ~ %
Enter "Conda deactivate"
to go back to the old environment.
Since this Python version is an ARM version, it will provide you with the most recent and potent speed advantages.
Conclusion
This post was able to demonstrate how to set up the most recent Python version and install Python on Apple Silicon.