Install miniconda on MacOS


One of the most used tools in data science field (alongside R) is Python with his enormous amount of libraries like NumPy, pandas or SciPy.

Alongside these there is also the web frontend Jupyter that makes it easy to create interactive Python notebooks which are locally served on your system. If this is not your cup of tea there are several existing hosted solution like Google Colaboratory

For compatibility reasons MacOS has only Python 2 installed per default (even though Python 3 will be installed alongside XCode). While there are official installer for Python 3 on MacOS there are other, easier and cleaner, ways to achieve this.

This can be done using a package manager like Homebrew or a Python distribution like Anaconda.

Installing Anaconda has the benefit that all the Python packages (as Python 3 itself) will be installed in the user directory and thus can be easily removed or reinstalled.

While Anaconda is a complete package with a nice GUI of the anaconda-navigator it’s quite bloated and has probably more packages than a upcoming data scientists needs. Here you can use a minimal version of Anaconda called miniconda (which is a minimal installer for conda package manager).

Let’s see how to quickly do it on MacOS!

Prerequisite

  • a MacOS system running MacOS Mojave or never.

Download & Install Miniconda package

chmod +x Miniconda3-latest-MacOSX-x86_64.sh
  • execute the installer and follow the provided instruction (like accepting the license terms):
./Miniconda3-latest-MacOSX-x86_64.sh
  • Per Default miniconda will be installed in /Users/[username]/miniconda3. This can be changed in the installer.
Do you accept the license terms? [yes|no]
[no] >>> yes

Miniconda3 will now be installed into this location:
/Users/kris/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/Users/kris/miniconda3] >>> 
PREFIX=/Users/kris/miniconda3
Unpacking payload ...
Collecting package metadata (current_repodata.json): done                                                               
Solving environment: done

## Package Plan ##

  environment location: /Users/kris/miniconda3

  added / updated specs:
    - brotlipy==0.7.0=py38h9ed2024_1003
    - ca-certificates==2020.10.14=0
    - certifi==2020.6.20=pyhd3eb1b0_3
    - cffi==1.14.3=py38h2125817_2
    - chardet==3.0.4=py38hecd8cb5_1003
    - conda-package-handling==1.7.2=py38h22f3db7_0
    - conda==4.9.2=py38hecd8cb5_0
    - cryptography==3.2.1=py38hbcfaee0_1
    - idna==2.10=py_0
    - libcxx==10.0.0=1
    - libedit==3.1.20191231=h1de35cc_1
    - libffi==3.3=hb1e8313_2
    - ncurses==6.2=h0a44026_1
    - openssl==1.1.1h=haf1e3a3_0
    - pip==20.2.4=py38hecd8cb5_0
    - pycosat==0.6.3=py38h1de35cc_1
    - pycparser==2.20=py_2
    - pyopenssl==19.1.0=pyhd3eb1b0_1
    - pysocks==1.7.1=py38_1
    - Python.app==2=py38_10
    - Python==3.8.5=h26836e1_1
    - readline==8.0=h1de35cc_0
    - requests==2.24.0=py_0
    - ruamel_yaml==0.15.87=py38haf1e3a3_1
    - setuptools==50.3.1=py38hecd8cb5_1
    - six==1.15.0=py38hecd8cb5_0
    - sqlite==3.33.0=hffcf06c_0
    - tk==8.6.10=hb0a8c7a_0
    - tqdm==4.51.0=pyhd3eb1b0_0
    - urllib3==1.25.11=py_0
    - wheel==0.35.1=pyhd3eb1b0_0
    - xz==5.2.5=h1de35cc_0
    - yaml==0.2.5=haf1e3a3_0
    - zlib==1.2.11=h1de35cc_3

The following NEW packages will be INSTALLED:

  brotlipy           pkgs/main/osx-64::brotlipy-0.7.0-py38h9ed2024_1003
  ca-certificates    pkgs/main/osx-64::ca-certificates-2020.10.14-0
  certifi            pkgs/main/noarch::certifi-2020.6.20-pyhd3eb1b0_3
  cffi               pkgs/main/osx-64::cffi-1.14.3-py38h2125817_2
  chardet            pkgs/main/osx-64::chardet-3.0.4-py38hecd8cb5_1003
  conda              pkgs/main/osx-64::conda-4.9.2-py38hecd8cb5_0
  conda-package-han~ pkgs/main/osx-64::conda-package-handling-1.7.2-py38h22f3db7_0
  cryptography       pkgs/main/osx-64::cryptography-3.2.1-py38hbcfaee0_1
  idna               pkgs/main/noarch::idna-2.10-py_0
  libcxx             pkgs/main/osx-64::libcxx-10.0.0-1
  libedit            pkgs/main/osx-64::libedit-3.1.20191231-h1de35cc_1
  libffi             pkgs/main/osx-64::libffi-3.3-hb1e8313_2
  ncurses            pkgs/main/osx-64::ncurses-6.2-h0a44026_1
  openssl            pkgs/main/osx-64::openssl-1.1.1h-haf1e3a3_0
  pip                pkgs/main/osx-64::pip-20.2.4-py38hecd8cb5_0
  pycosat            pkgs/main/osx-64::pycosat-0.6.3-py38h1de35cc_1
  pycparser          pkgs/main/noarch::pycparser-2.20-py_2
  pyopenssl          pkgs/main/noarch::pyopenssl-19.1.0-pyhd3eb1b0_1
  pysocks            pkgs/main/osx-64::pysocks-1.7.1-py38_1
  Python             pkgs/main/osx-64::Python-3.8.5-h26836e1_1
  Python.app         pkgs/main/osx-64::Python.app-2-py38_10
  readline           pkgs/main/osx-64::readline-8.0-h1de35cc_0
  requests           pkgs/main/noarch::requests-2.24.0-py_0
  ruamel_yaml        pkgs/main/osx-64::ruamel_yaml-0.15.87-py38haf1e3a3_1
  setuptools         pkgs/main/osx-64::setuptools-50.3.1-py38hecd8cb5_1
  six                pkgs/main/osx-64::six-1.15.0-py38hecd8cb5_0
  sqlite             pkgs/main/osx-64::sqlite-3.33.0-hffcf06c_0
  tk                 pkgs/main/osx-64::tk-8.6.10-hb0a8c7a_0
  tqdm               pkgs/main/noarch::tqdm-4.51.0-pyhd3eb1b0_0
  urllib3            pkgs/main/noarch::urllib3-1.25.11-py_0
  wheel              pkgs/main/noarch::wheel-0.35.1-pyhd3eb1b0_0
  xz                 pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
  yaml               pkgs/main/osx-64::yaml-0.2.5-haf1e3a3_0
  zlib               pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3


Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[yes] >>> yes
no change     /Users/kris/miniconda3/condabin/conda
no change     /Users/kris/miniconda3/bin/conda
no change     /Users/kris/miniconda3/bin/conda-env
no change     /Users/kris/miniconda3/bin/activate
no change     /Users/kris/miniconda3/bin/deactivate
no change     /Users/kris/miniconda3/etc/profile.d/conda.sh
no change     /Users/kris/miniconda3/etc/fish/conf.d/conda.fish
no change     /Users/kris/miniconda3/shell/condabin/Conda.psm1
no change     /Users/kris/miniconda3/shell/condabin/conda-hook.ps1
no change     /Users/kris/miniconda3/lib/Python3.8/site-packages/xontrib/conda.xsh
no change     /Users/kris/miniconda3/etc/profile.d/conda.csh
modified      /Users/kris/.bash_profile

==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 

conda config --set auto_activate_base false

Thank you for installing Miniconda3!

The newly created bin directory will be added to the user PATH in his .bash_profile and thus the newly installed Python 3 can be directly called:

Now that miniconda with the conda package manager has been installed you can use the conda command to create a new conda environment and/or install new Python packages like jupyter.

Conclusion

In this article we’ve installed miniconda in MacOS which provides an up to date Python 3 installation alongside the conda package manager. From here on a huge amount of Python packages can be installed using conda.


↑ back to top ↑