Rocks downloading
Install Python On Mac Os X
Install Miniconda Python¶. There is a known issue with version 3.7 of Anaconda Python and certain versions of the Mac OSX operating system. We strongly recommend that you use python 3.6 on OSX to avoid any problems. Python for Mac OS X Python comes pre-installed on Mac OS X so it is easy to start using. However, to take advantage of the latest versions of Python, you will need to download and install newer versions alongside the system ones. The easiest way to do that is to install one of the binary installers for OS X from the Python Download page. Mac OS X An installer is available on the wxPython site, for both PPC and Intel Macs. If you wish to build it yourself, you should follow the instruction described here. The following steps get you started with installing a new version of Python on your Mac OS X system. Navigate to the Python download site with your browser. You see information regarding the latest version of Python. Click the appropriate link for your version of OS X.
Note
Using Anaconda in a commercial setting? You may need to use Anaconda Commercial Edition. If you have already purchased Commercial Edition, please proceed to the Authenticating Commercial Edition section after completing your installation here.
Haven’t purchased Commercial Edition yet? Visit https://anaconda.cloud/register to get started.
You can install Anaconda using either the graphical installer (“wizard”) or thecommand line (“manual”) instructions below. If you are unsure, choose the graphical install.
macOS graphical install¶
Download the graphical macOS installer for your version of Python.
RECOMMENDED: Verify data integrity with SHA-256.For more information on hashes, see What about cryptographic hash verification?
Double-click the downloaded file and click continue to start the installation.
Answer the prompts on the Introduction, Read Me, and License screens.
Click the Install button to install Anaconda in your ~/opt directory (recommended):
OR, click the Change Install Location button to install in another location (not recommended).
On the Destination Select screen, select Install for me only.
Note
If you get the error message “You cannot install Anaconda in this location,” reselect Install for me only.
Click the continue button.
Optional: To install PyCharm for Anaconda, click on the link to https://www.anaconda.com/pycharm.
Or to install Anaconda without PyCharm, click the Continue button.
A successful installation displays the following screen:
Verify your installation.
Using the command-line install¶
Use this method if you prefer to use a terminal window.
In your browser, download the command-line version of themacOS installer for your system.
RECOMMENDED: Verify data integrity with SHA-256.For more information on hash verification, see cryptographic hash validation.
Open a terminal and run the following:
Note
Replace
/path/filename
with your installation’s path and filename.Install for Python 3.7 or 2.7:
For Python 3.7 enter the following:
For Python 2.7, open the Terminal.app or iTerm2 terminal application and then enter the following:
Note
Include the
bash
command regardless of whether or not you are using the Bash shell.Note
Replace
~/Downloads
with your actual path andAnaconda3-2020.02-MacOSX-x86_64.sh
with actual name of the file you downloaded.The installer prompts “In order to continue the installation process, please review the license agreement.”Click Enter to view the license terms.
Scroll to the bottom of the license terms and enter yes to agree to them.
The installer prompts you to Press Enter to confirm the location, Press CTRL-C to cancel the installationor specify an alternate installation directory. If you confirm the default location,it will display
PREFIX=/home/<user>/anaconda<2or3>
and continue the installation.Note
Unlike the graphical install, installing the shell file will place it in ~/anaconda<2 or 3> by default,not ~/opt. This is due to limitations with installing .pkg files on macOS Catalina.
Installation may take a few minutes to complete.
Note
We recommend you accept the default install location. Do not choose the path as /usr for theAnaconda/Miniconda installation.
The installer prompts “Do you wish the installer to initialize Anaconda3by running conda init?” We recommend “yes”.
Note
If you enter “no”, then conda will not modify your shell scripts at all.In order to initialize after the installation process is done, first run
source<pathtoconda>/bin/activate
and then runcondainit
.Note
If you are on macOS Catalina, the new default shell is zsh.You will instead need to run
source<pathtoconda>/bin/activate
followed bycondainitzsh
.The installer displays “Thank you for installing Anaconda!”
Optional: The installer describes the partnership between Anaconda and JetBrains andprovides a link to install PyCharm for Anaconda athttps://www.anaconda.com/pycharm.
Close and open your terminal window for the Anaconda installation to take effect.
To control whether or not each shell session has the base environmentactivated or not, run
condaconfig--setauto_activate_baseFalseorTrue
. To run conda from anywhere without having the base environmentactivated by default, usecondaconfig--setauto_activate_baseFalse
.This only works if you have runcondainit
first.Note
condainit
is available in conda versions 4.6.12 and later.Verify your installation.
What’s next?¶
Get started programming quickly with Anaconda in the Getting started with Anaconda guide.
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. 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
Python Os X
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.
To install Homebrew, open Terminal
oryour favorite OS X terminal emulator and run
Install Python 3 On Mac Os X
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¶
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).
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.