Run the Python installer package and install Python 3 onto the Mac Python 3.8.x requires about 100mb of disk space to install. Installation is quick, and you'll have Python 3.x alongside Python 2.x on the Mac. Once Python 3 is installed you will find a Python3 folder within the /Applications directory of your Mac. When you install Python 3 on a Mac, it does not update the python command to use Python 3 instead of Python 2. Instead, to run Python 3, you have to use the python3 command. Here's how to fix this. Prerequisites for installing Python3 on Mac Install Xcode. Xcode is Apple's Integrated Development Environment (IDE). You might already have Xcode on your Mac.
Installing Miniconda Mac. Follow the below instructions to install the latest Miniconda version for Mac. Go to the Miniconda Download page and download the Python 3.7 Mac OS X 64-bit.pkg installer. After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults. I installed Python 3.7.7 using Homebrew, and you can compare the differences in the installation processes by reading both Installing the latest version of Python on Mac OS Catalina and overriding the old default pre-installed version and this post. After a couple of failed attempts, I finally found the best way to install Python 3.8.0+ on my.
Mac OS X comes with Python 2.7 out of the box.
You do not need to install or configure anything else to use Python 2. Theseinstructions document the installation of Python 3.
The version of Python that ships with OS X is great for learning, but it's notgood for development. Mac apps 2014. The version shipped with OS X may be out of date from theofficial current Python release,which is considered the stable production version.
Doing it Right¶
Let's install a real version of Python.
Before installing Python, you'll need to install GCC. GCC can be obtainedby downloading Xcode, the smallerCommand Line Tools (must have anApple account) or the even smaller OSX-GCC-Installerpackage.
Note
If you already have Xcode installed, do not install OSX-GCC-Installer.In combination, the software can cause issues that are difficult todiagnose.
Note
If you perform a fresh install of Xcode, you will also need to add thecommandline tools by running xcode-select--install
on the terminal.
While OS X comes with a large number of Unix utilities, those familiar withLinux systems will notice one key component missing: a package manager.Homebrew fills this void.
Change where screenshots are saved mac. To install Homebrew, open Terminal
oryour favorite OS X terminal emulator and run
The script will explain what changes it will make and prompt you before theinstallation begins.Once you've installed Homebrew, insert the Homebrew directory at the topof your PATH
environment variable. You can do this by adding the followingline at the bottom of your ~/.profile
file
If you have OS X 10.12 (Sierra) or older use this line instead
Now, we can install Python 3:
This will take a minute or two.
Pip¶
Brew Install Python 2.7
Homebrew installs pip
pointing to the Homebrew'd Python 3 for you.
Working with Python 3¶
At this point, you have the system Python 2.7 available, potentially theHomebrew version of Python 2 installed, and the Homebrewversion of Python 3 as well.
will launch the Homebrew-installed Python 3 interpreter.
will launch the Homebrew-installed Python 2 interpreter (if any).
Python 3 Mac Os
will launch the Homebrew-installed Python 3 interpreter.
If the Homebrew version of Python 2 is installed then pip2
will point to Python 2.If the Homebrew version of Python 3 is installed then pip
will point to Python 3.
The rest of the guide will assume that python
references Python 3.
Pipenv & Virtual Environments¶
The next step is to install Pipenv, so you can install dependencies and manage virtual environments.
A Virtual Environment is a tool to keep the dependencies required by different projectsin separate places, by creating virtual Python environments for them. It solves the'Project X depends on version 1.x but, Project Y needs 4.x' dilemma, and keepsyour global site-packages directory clean and manageable.
For example, you can work on a project which requires Django 1.10 while alsomaintaining a project which requires Django 1.8.
So, onward! To the Pipenv & Virtual Environments docs!
This page is a remixed version of another guide,which is available under the same license.
This is my preferred way to install Python and Jupyter notebook for doing scientific data analysis. There are many alternative ways of doing this that you can find on Google. I'm doing this on a MacBook Pro (Retina, 13-inch, Early 2015) with macOS High Sierra 10.13.3.
In the past, I used virtualenv
to manage virtual environments with Python 2. Python3 has built-in handling of virtual environments, so I use that here instead. If you need to use Python 2, then you'll want to install virtualenv
(see first link at the bottom).
Install Homebrew
All of these steps are done in the Mac OS Terminal, so start that first.
First install XCode:
![Install Python 3 On Mac Install Python 3 On Mac](https://i0.wp.com/www.supportyourtech.com/wp-content/uploads/2017/02/how-get-emojis-iphone-7-8.jpg?fit=350%2C622&ssl=1)
Latest mac ios. Install Homebrew:
Open or create the file ~/.bash_profile and write:
Homebrew Install Python3
Install Python 3
As of 2018-4-9, this will install Python 3 (I think previously it installed Python 2):
Set up virtual environment
By default, Python 3 comes with the ability to create virtual environments.
Make a folder to host your virtual envs:
Create a virtual env for Jupyter:
Run virtual environment and Jupyter
![Install Install](https://mac-cdn.softpedia.com/screenshots/Adobe-Audition_3.jpg)
Latest mac ios. Install Homebrew:
Open or create the file ~/.bash_profile and write:
Homebrew Install Python3
Install Python 3
As of 2018-4-9, this will install Python 3 (I think previously it installed Python 2):
Set up virtual environment
By default, Python 3 comes with the ability to create virtual environments.
Make a folder to host your virtual envs:
Create a virtual env for Jupyter:
Run virtual environment and Jupyter
Start the virtual env:
Install packages for scientific computing:
Run Jupyter:
A browser window will open with the Jupyter file browser in your current working directory.
Exit Jupyter and virtual environment
Jupyter notebook will run in your terminal window until you close it (with Ctrl-C).
You can close the virtual environment with:
UPDATE 2018-04-19: A very useful (and IMO essential) addition to Jupyter notebook is the Table of Contents extension. I show how I install this in a different blog post.
References
- The steps above are mostly based on Maria Mele's 'Install Python 2.7, virtualenv and virtualenvwrapper on OS X Mavericks/Yosemite'
- Documentation on Python 3 virtual environments
- Explanation of how Homebrew installs Python — i.e. why Python 3 isn't linked to the command`python`, which motivated some of my deviations from the above blog post