Skip to content

Instantly share code, notes, and snippets.

@fyears
Last active February 6, 2024 09:59
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save fyears/7601881 to your computer and use it in GitHub Desktop.
Save fyears/7601881 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:

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.

@varuzhnikov
Copy link

Hi! Can you download now distribution from link http://www.lfd.uci.edu/~gohlke/pythonlibs/tjzu5yco/numpy-MKL-1.8.0.win-amd64-py2.7.exe ?Because I have network error after 20mb's downloaded

@fyears
Copy link
Author

fyears commented Apr 9, 2014

@varuzhnikov The link is broken since there are newer versions being released. You should go to the website and click the links manually to obtain the right new links.

@grisaitis
Copy link

I think this assumes that dependencies are already installed, i.e. basic linear algebra subroutines (BLAS).

Here's a tut for including those, before pipping: http://iqbalnaved.wordpress.com/2013/11/12/installing-scikit-learn-for-virtualenv-python-2-7-5-on-64-bit-ubuntu-13-10/

@RacingTadpole
Copy link

Hi. thanks for this. Can you elaborate a bit more on "importantly, copy the files of pyside and shiboken into .venv so that you can use pyside in virtualenv"? shiboken has been installed into /usr/local/Cellar/shiboken/1.2.2/, with subdirectories including bin, lib, include and share; my virtualenv directory also has bin, lib, include and share folders. Which files in which of these directories should I copy across? Thanks!

@benjaminirving
Copy link

Hi. Thanks for the gist.

brew search gfortran now states that GNU Fortran is provided as part of GCC. Would you mind updating? I'm new to OSx so haven't quite figured out what complications are going to arise with the clang compiler if I "brew install gcc"

@endolith
Copy link

How do you install pyqt or pyside under virtualenv? pip does not work

@jaguarondi
Copy link

How do you install pyqt or pyside under virtualenv? pip does not work

It seems you can't, see this stackoverflow explanation.

Basically, create symbolic link of PyQt4 to your virtual env, same for PySide, sip, etc.
ln -s /usr/lib/python2.7/dist-packages/PyQt4/ ~/.virtualenvs/myEnv/lib/python2.7/site-packages/

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