Mac Installation - QuantSoftware/QuantSoftwareToolkit GitHub Wiki
This is documentation of the step by step installation process for QSTK on MacOSx. The process has been completely tested on Mountain Lion and testing on other environments is still pending.
Homebrew
The recommended process for installation of python dependencies and installation is using Homebrew.
-
Installing homebrew on MacOS:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
This will install homebrew in
/usr/local/bin
. Now you need to make sure everything uses homebrew versions instead of the default installation. Example: we want to use homebrew's python instead of the default version by Apple.echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
Now restart the terminal or
source ~/.bash_profile
to edit thePATH
variable. Then run the command below to make sure everything works.brew doctor
-
Installing python and major dependencies:
Install Homebrew's python and then update pip and setuptools which are automatically installed with python. The default apple version of python has several dependency issues so it is better to use the homebrew version.
brew install python pip install --upgrade setuptools pip install --upgrade pip
Test if you have the right version. The output of
which python
should be/usr/local/bin/python
.Installing the major packages that are used by all projects.
pip install nose pip install virtualenv
-
Install Numpy, Scipy and Matplotlib
Numpy, Scipy and Matplotlib are big libraries which are used by almost all python projects. So it is better to install them globally then configure a virtualenv everytime. Also the compilation process of the three libraries is big so we use homebrew to install them instead of pip.
Apple discontinued the default fortran compiler that used to come preinstalled. So we used homebrew to install a fortran compiler as well.
brew install gfortran
Add
homebrew/science
andsamueljohn/python
taps to your formula lists.brew tap samueljohn/python brew tap homebrew/science
Now install the three packages.
brew install numpy brew install scipy brew install matplotlib
Now you have all the major libraries installed using homebrew.
-
Create a directory for installation of QSTK
mkdir ~/QSTK cd ~/QSTK
-
Creating a virtual environment inside QSTK directory.
We will create a virtual environment inside the QSTK directory to avoid conflict with other projects and system configurations. In the second command we activate the virtual environment.
virtualenv env --distribute --system-site-packages source ~/QSTK/env/bin/activate
-
Installing the other dependencies and QSTK inside the virtual environment.
Now that we are in the active virtual environment. We will install the other dependencies using pip. So lets start by installing pandas, scikits.statsmodels and scikit-learn.
pip install pandas pip install scikits.statsmodels pip install scikit-learn pip install cvxopt
Now lets install QSTK in this directory using pip as well.
pip install QSTK
Now we have installed QSTK successfully.
-
Make python run as a framework for matplotlib
We will execute the following command
echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
-
Downloads Examples and take QSTK for a spin.
curl -O https://spark-public.s3.amazonaws.com/compinvesting1/QSTK-Setups/Examples.zip unzip Examples.zip
Now we have downloaded the examples for QSTK. Lets validate the installation first to make sure everything is in place.
python Validation.py
Now that the validation is a success. Lets test drive QSTK.
python Basic/tutorial1.py
You should see pdfs created in the ~/QSTK/Basic directory. Which can be opened using finder or using the
open
command. -
Deactivate your virtual environment using the deactivate command.
deactivate
-
Usage instructions: Now anytime you want to work using QSTK you need to activate the environment first using the command.
source ~/QSTK/env/bin/activate
Once you finish working just deactivate the virtual environment.
deactivate
-
Uninstalling QSTK: Just remove the QSTK directory completely, please make sure you don't have an active virtual environment, if it is please deactivate first. Note that though it is possible to remove homebrew as well, we do not recommend it.
rm -rf ~/QSTK
Macports
This is work in progress. We're working on testing the installation using macports and would update the wiki soon.