Roman Ruiz

Full Stack Developer

Python Installation on Mac

On Mac, use Homebrew to install Python 3, then use pipenv to manage individual project dependencies.

brew install python3

Add aliases to ~/.zshrc file:

alias python=python3
alias pip=pip3

Test that Python 3.x and pip are working:

python --version
pip --version

Check what packages are installed globally with pip:

pip list

Package Version
---------- -------
pip 20.1.1
setuptools 49.2.0
wheel 0.34.2

Install pipenv, the per-project package manager:

pip install --user pipenv

which gave me a warning

WARNING: The scripts pipenv and pipenv-resolver are installed in '/Users/rr214/Library/Python/3.8/bin' which is not on PATH.

so I added the directory to my path:

export PATH=$PATH:/Users/rr214/Library/Python/3.8/bin

Create a project

mkdir my-demo
cd my-demo
pipenv install requests

Now we have a pipenv with our first dependency, requests.

Create a little test script, main.py:

import requests

response = requests.get('https://httpbin.org/ip')

print('Your IP is {0}'.format(response.json()['origin']))

And run:

pipenv run python main.py