Installing python3 on Mac - rajivkanaujia/alphaworks GitHub Wiki

Install python3 via Homebrew

Use this to install Python 3 if your Mac does not come with it. Run following command and check the output

    $ python3 --version
      Python 3.7.3

If you don't have it installed, continue to install it.

Run following command on Terminal

This will take a while to run

    $ brew install python3
    Updating Homebrew...
    ==> Auto-updated Homebrew!
    Updated 1 tap (homebrew/cask).
    ==> Updated Casks
    google-chrome

    ==> Installing dependencies for python: gdbm, [email protected], readline, sqlite and xz
    ==> Installing python dependency: gdbm
    ==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.catalina.bottle
    ######################################################################## 100.0%
    ==> Pouring gdbm-1.18.1.catalina.bottle.1.tar.gz
    🍺  /usr/local/Cellar/gdbm/1.18.1: 20 files, 602.8KB
    ==> Installing python dependency: [email protected]
    ==> Downloading https://homebrew.bintray.com/bottles/[email protected]
    ==> Downloading from https://akamai.bintray.com/19/1926679569c6af5337de812d86f4d
    ######################################################################## 100.0%
    ==> Pouring [email protected]
    ==> Caveats
    A CA file has been bootstrapped using certificates from the system
    keychain. To add additional certificates, place .pem files in
    /usr/local/etc/[email protected]/certs

    and run
    /usr/local/opt/[email protected]/bin/c_rehash

    [email protected] is keg-only, which means it was not symlinked into /usr/local,
    because macOS provides LibreSSL.

    If you need to have [email protected] first in your PATH run:
    echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile

    For compilers to find [email protected] you may need to set:
    export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
    export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

    ==> Summary
    🍺  /usr/local/Cellar/[email protected]/1.1.1g: 8,059 files, 18MB
    ==> Installing python dependency: readline
    ==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.4.catalina.bot
    ==> Downloading from https://akamai.bintray.com/6a/6ae1c8e7c783f32bd22c6085caa4d
    ######################################################################## 100.0%
    ==> Pouring readline-8.0.4.catalina.bottle.tar.gz
    ==> Caveats
    readline is keg-only, which means it was not symlinked into /usr/local,
    because macOS provides BSD libedit.

    For compilers to find readline you may need to set:
    export LDFLAGS="-L/usr/local/opt/readline/lib"
    export CPPFLAGS="-I/usr/local/opt/readline/include"

    ==> Summary
    🍺  /usr/local/Cellar/readline/8.0.4: 48 files, 1.5MB
    ==> Installing python dependency: sqlite
    ==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.31.1.catalina.bott
    ==> Downloading from https://akamai.bintray.com/e0/e09e8c96db88178e4f47b0cdab647
    ######################################################################## 100.0%
    ==> Pouring sqlite-3.31.1.catalina.bottle.tar.gz
    ==> Caveats
    sqlite is keg-only, which means it was not symlinked into /usr/local,
    because macOS already provides this software and installing another version in
    parallel can cause all kinds of trouble.

    If you need to have sqlite first in your PATH run:
    echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

    For compilers to find sqlite you may need to set:
    export LDFLAGS="-L/usr/local/opt/sqlite/lib"
    export CPPFLAGS="-I/usr/local/opt/sqlite/include"

    ==> Summary
    🍺  /usr/local/Cellar/sqlite/3.31.1: 11 files, 4MB
    ==> Installing python dependency: xz
    ==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.5.catalina.bottle.ta
    ==> Downloading from https://akamai.bintray.com/2d/2dcc8e0121c934d1e34ffdb37fcd7
    ######################################################################## 100.0%
    ==> Pouring xz-5.2.5.catalina.bottle.tar.gz
    🍺  /usr/local/Cellar/xz/5.2.5: 92 files, 1.1MB
    ==> Installing python
    ==> Downloading https://homebrew.bintray.com/bottles/python-3.7.7.catalina.bottl
    ==> Downloading from https://akamai.bintray.com/ac/acd595852aecc2bfa46c57d86db71
    ######################################################################## 100.0%
    ==> Pouring python-3.7.7.catalina.bottle.tar.gz
    ==> /usr/local/Cellar/python/3.7.7/bin/python3 -s setup.py --no-user-cfg install
    ==> /usr/local/Cellar/python/3.7.7/bin/python3 -s setup.py --no-user-cfg install
    ==> /usr/local/Cellar/python/3.7.7/bin/python3 -s setup.py --no-user-cfg install
    ==> Caveats
    Python has been installed as
    /usr/local/bin/python3

    Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
    `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
    /usr/local/opt/python/libexec/bin

    You can install Python packages with
    pip3 install <package>
    They will install into the site-package directory
    /usr/local/lib/python3.7/site-packages

    See: https://docs.brew.sh/Homebrew-and-Python
    ==> Summary
    🍺  /usr/local/Cellar/python/3.7.7: 4,006 files, 61.2MB
    ==> Caveats
    ==> [email protected]
    A CA file has been bootstrapped using certificates from the system
    keychain. To add additional certificates, place .pem files in
    /usr/local/etc/[email protected]/certs

    and run
    /usr/local/opt/[email protected]/bin/c_rehash

    [email protected] is keg-only, which means it was not symlinked into /usr/local,
    because macOS provides LibreSSL.

    If you need to have [email protected] first in your PATH run:
    echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile

    For compilers to find [email protected] you may need to set:
    export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
    export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

    ==> readline
    readline is keg-only, which means it was not symlinked into /usr/local,
    because macOS provides BSD libedit.

    For compilers to find readline you may need to set:
    export LDFLAGS="-L/usr/local/opt/readline/lib"
    export CPPFLAGS="-I/usr/local/opt/readline/include"

    ==> sqlite
    sqlite is keg-only, which means it was not symlinked into /usr/local,
    because macOS already provides this software and installing another version in
    parallel can cause all kinds of trouble.

    If you need to have sqlite first in your PATH run:
    echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

    For compilers to find sqlite you may need to set:
    export LDFLAGS="-L/usr/local/opt/sqlite/lib"
    export CPPFLAGS="-I/usr/local/opt/sqlite/include"

    ==> python
    Python has been installed as
    /usr/local/bin/python3

    Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
    `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
    /usr/local/opt/python/libexec/bin

    You can install Python packages with
    pip3 install <package>
    They will install into the site-package directory
    /usr/local/lib/python3.7/site-packages

    See: https://docs.brew.sh/Homebrew-and-Python

Install pip3 via Homebrew

    $ pip install --upgrade setuptools
    -bash: pip: command not found
    $ pip3 install --upgrade setuptools
    Collecting setuptools
      Using cached setuptools-35.0.1-py2.py3-none-any.whl
    Collecting packaging>=16.8 (from setuptools)
      Using cached packaging-16.8-py2.py3-none-any.whl
    Collecting appdirs>=1.4.0 (from setuptools)
      Using cached appdirs-1.4.3-py2.py3-none-any.whl
    Collecting six>=1.6.0 (from setuptools)
      Using cached six-1.10.0-py2.py3-none-any.whl
    Collecting pyparsing (from packaging>=16.8->setuptools)
      Using cached pyparsing-2.2.0-py2.py3-none-any.whl
    Installing collected packages: six, pyparsing, packaging, appdirs, setuptools
      Found existing installation: setuptools 32.2.0
        Uninstalling setuptools-32.2.0:
          Successfully uninstalled setuptools-32.2.0
    Successfully installed appdirs-1.4.3 packaging-16.8 pyparsing-2.2.0 setuptools-35.0.1 six-1.10.0

Make changes to path

    export PATH=/usr/local/bin:$PATH
    export PATH=/usr/local/opt/sqlite/bin:$PATH

Source the .bash_profile

    $ source ~/.bash_profile

Check the version of python3 and pip3

    $ python3 --version
    Python 3.6.1

    $ pip3 --version
    pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Note: If you like the instructions here, please refer it on your posts/documentation. Contact me if there are corrections needed.

⚠️ **GitHub.com Fallback** ⚠️