Skip to content

Instantly share code, notes, and snippets.

@wsrzx
Created June 27, 2018 15:24
Show Gist options
  • Save wsrzx/625cd5efbede607de3883d5c34860986 to your computer and use it in GitHub Desktop.
Save wsrzx/625cd5efbede607de3883d5c34860986 to your computer and use it in GitHub Desktop.
Mac OS High Sierra Python Dev Environment Setup

Install iTerm2

Download and install https://www.iterm2.com/

Install the Xcode Command Line Tools directly from the command line

xcode-select --install

Install Hombrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Tell the system to use programs installed by Hombrew (in /usr/local/bin) rather than the OS default if it exists. We do this by adding /usr/local/bin to your $PATH environment variable:

$ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

Open a new terminal tab with Cmd+T (you should also close the old one), then run the following command to make sure everything works:

brew doctor

Setup terminal

cd ~
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.bash_profile
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.bash_prompt
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.aliases

Git

brew install git

Let's set up some basic git configuration

$ cd ~
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.gitconfig

$ git config --global user.name "Your Name Here"
$ git config --global user.email "your_email@youremail.com"

$ git config --global credential.helper osxkeychain

Python & Virtual env

brew install python

pip3 install pipenv

Update ~/.bash_profile to setup virtualenv, edit the file and add:

#virtualenv
export WORKON_HOME=$HOME/Source/.virtualenvs
export PROJECT_HOME=$HOME/Source
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

source /usr/local/bin/virtualenvwrapper.sh

then:

$ source ~/.bash_profile

mysqlclient

See https://github.com/PyMySQL/mysqlclient-python

brew install mysql-connector-c

Open the mysql_config and

Change (on macOS, on or about line 112:)

# Create options
libs="-L$pkglibdir"
libs="$libs -l "

to

# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"

Now install from pip

pip3 install mysqlclient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment