Skip to content

Instantly share code, notes, and snippets.

@kisna72
Forked from fyears/note.md
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kisna72/12842e361c8e484dcbaa to your computer and use it in GitHub Desktop.
Save kisna72/12842e361c8e484dcbaa to your computer and use it in GitHub Desktop.
how to install scipy numpy matplotlib ipython in virtualenv

if you are using linux, unix, os x:

pip install -U setuptools
pip install -U pip

pip install numpy
pip install scipy
pip install matplotlib
#pip install PySide
pip install ipython[all]
pip install patsy
pip install pandas
pip install sympy
pip install nose

pip install statsmodels
pip install zipline
pip install quandl
pip install scikit-learn
pip install pillow
ipython profile create
ipython qtconsole --matplotlib inline
# ipython
# ipython notebook

If you are using OS X, you should do this first:

brew install python
brew tap homebrew/science
brew install gfortran
brew install pkg-config freetype libpng
brew install pyside # yeah i know...
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
pip install -U setuptools
pip install -U pip
pip install -U virtualenv
virtualenv ~/.venv
source ~/.venv/bin/activate

# importantly, copy the files of pyside and shiboken into .venv
# so that you can use pyside in virtualenv

# pip install anything except pyside

change the font size of ipython qtconsole

go to ~/.ipython/profile_default/ipython_qtconsole_config.py and modify the you-know-it line to c.IPythonWidget.font_size = 14

startup

the best practise of starting:

ipython qtconsole --matplotlib inline

mirror

set up the mirror (linux and osx):

nano ~/.pip/pip.conf
[global]
index-url = http://pypi.mirrors.ustc.edu.cn/simple

To avoid any troubles, install visual studio 2008 if you are using py2.7 or visual studio 2010 if you are using py3. Express edition is enough. Another way is to install Microsoft Visual C++ Compiler for Python 2.7 if you are using Python 2.7.

Go to the following address to download the complied packages:

  • Most packages are in wheel format. Download the wheel for your python version and system architecture.

http://www.lfd.uci.edu/~gohlke/pythonlibs/

numpy-MKL
scipy

and place the .exe file in home directory.

Run the following command in cmd:

(you should adjust the file names)

virtualenv venv
venv\Scripts\activate.bat
pip install -U setuptools
pip install -U pip

easy_install numpy-MKL.exe
easy_install scipy.exe
pip install matplotlib
pip install PySide
pip install ipython[all]
pip install patsy
pip install pandas
pip install sympy
pip install nose

# others
pip install statsmodels
pip install zipline
pip install quandl
pip install scikit-learn

# create the profile of ipython
ipython profile create

Installation finished.

Next every time want to use the stack, type following in cmd:

venv\Scripts\activate.bat
ipython qtconsole --matplotlib inline
# ipython
# ipython notebook

Here you go.

Extra Notes on Installing matplotlib

If you want to install matplotlib, you must ensure that you have the correct type of python installed on your machine. eg. If you have 64 bit windows machine, install 64 bit python. Else everytime you import pyplot, you will get dll not found error.

After you download the matplotlib wheel from gohlke's website, install it as pip install <name of the wheel file> Since most of the packages by gohlke are in .whl format, you can run pip install <wheel file name> to install them.

Next go to your system python installation and copy tcl folder. Inside your virtualenv, run pyton and type the following: import sys sys.prefix

Paste the tcl folder in your sys.prefix folder. This folder should be the same as your virtualenv folder.

You should be able to use matplotlib now.

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