Skip to content

Instantly share code, notes, and snippets.

@sb2nov
Forked from elyase/how_to.md
Created June 29, 2013 16:56
Show Gist options
  • Save sb2nov/5891842 to your computer and use it in GitHub Desktop.
Save sb2nov/5891842 to your computer and use it in GitHub Desktop.
Install QSTK on mac.

This should automatically install QSTK with all dependencies in a self contained Python folder in a Mac(tested on Mountain Lion 10.8.2). In a terminal run:

curl -L https://gist.github.com/elyase/5031291/raw/74d44cbb4c7af2cc98111dc8e4afa135627a49e7/install_QSTK.sh | bash

Whenever you want to start working with QSTK, run in a terminal:

pythonbrew venv use QSTK

or simply use the alias:

qstk                  

(you might need to open a new terminal window for this to work) To uninstall everything(answer yes if asked):

rm -r $HOME/.pythonbrew
#!/bin/bash
#
# Installs QSTK software(From coursera computational Investing Part I with prof Tucker Balch) on Mac.
# ------------
# Usage: In a terminal run
# curl -L https://gist.github.com/elyase/5031291/raw/f518152ab92f019f1160f06ad561e962f943b1d3/install_QSTK.sh | bash
#
# Copyright (c) 2013, Yaser Martinez Palenzuela
# Licensed under MIT License.
# See: https://raw.github.com/gist/3151357/9e8e01df4ee12b1f04cd61e0ecee3ea8bd6f617b/mit-license.txt
echo "First installing pythonbrew..."
# Uncomment and edit next line to install your python(brew) in a different folder
#export PYTHONBREW_ROOT=/path/to/pythonbrew
curl -kLO http://xrl.us/pythonbrewinstall
chmod +x pythonbrewinstall
./pythonbrewinstall
echo "Adding pythonbrew to your terminal startup(bashrc,zshrc)..."
if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then
echo '[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc' >> $HOME/.zshrc
echo 'alias qstk="pythonbrew venv use QSTK"' >> $HOME/.zshrc
elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then
echo '[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc' >> ~/.bash_profile
echo 'alias qstk="pythonbrew venv use QSTK"' >> $HOME/.bash_profile
fi
source $HOME/.pythonbrew/etc/bashrc
#Install python 2.7.3
pythonbrew install 2.7.3
# Initializes the virtualenv
echo "Creating virtual environment for QSTK..."
pythonbrew venv init
pythonbrew venv create QSTK -p 2.7.3
# Use it
pythonbrew venv use QSTK
echo "Installing numpy, scipy, matplotlib..."
pip install numpy
pip install scipy
pip install matplotlib
echo "Installing pandas version 0.7.3..."
pip install -I pandas==0.7.3
echo "Installing scikit-learn"
pip install -I scikit-learn
echo "Downloading QSTK..."
curl -O http://pypi.python.org/packages/source/Q/QSTK/QSTK-0.2.5.tar.gz
echo "Installing QSTK..."
tar -xzvf QSTK-0.2.5.tar.gz
cd QSTK-0.2.5
python setup.py install
echo "Running QSTK tests..."
python Examples/Validation.py
echo "You are now good to go!! Whenever you want to start working with QSTK, run in a terminal:"
echo " pythonbrew venv use QSTK"
echo
echo "or simply:"
echo
echo " qstk (you might need to open a new terminal window)"
echo
echo "To uninstall everything you have just installed run(say yes if asked):"
echo
echo "rm -r $HOME/.pythonbrew"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment