Skip to content

Instantly share code, notes, and snippets.

@alexsavio
Last active December 31, 2015 05:59
Show Gist options
  • Save alexsavio/7944439 to your computer and use it in GitHub Desktop.
Save alexsavio/7944439 to your computer and use it in GitHub Desktop.
IPython notebooks on how to use Virtualenv and Virtualenvwrapper
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "Data analysis modules"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": "# Installing Data analysis tools"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### First create virtual environment\n\n mkvirtualenv <env_name>"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Install modules\n\n IPython\n \n pip install ipython[all]\n\n Numpy\n \n pip install numpy\n\n Test numpy\n \n pip install nose\n \n python -c 'import numpy; numpy.test()'\n \n Cython\n \n pip install cython \n\n Scipy\n\n pip install scipy\n\n Readline\n\n easy_install readline\n\n Other dependencies\n\n pip install python-dateutil sphinx pygments tornado"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Graphical libraries for GUI building and IPython QT console\n\n#### You can either install them inside the virtual environment:\n \n pip install pyside\n\n PyQt4 must be installed globally:\n \n sudo apt-get install python3-pyqt4\n \n or\n \n sudo apt-get install python-pyqt4\n \n\n#### We recommend installing them globally then linking from the virtual environment:\n\n First install them:\n \n sudo pip3 install pyside\n \n sudo apt-get install python3-qt4\n\n or\n \n sudo pip install pyside\n \n sudo apt-get install python-qt4"
},
{
"cell_type": "markdown",
"metadata": {},
"source": " Then link them (with the virtualenv activated):\n \n In [2] we can see a script to link any library to the virtual environment (save it in, e.g. symlink_pyqt4_and_sip.sh and execute it):"
},
{
"cell_type": "code",
"collapsed": false,
"input": "#!/bin/bash\n \nLIBS=( PyQt4 sip.so PySide )\nPYTHON_VERSION=python$(python -c \"import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))\")\nVAR=( $(which -a $PYTHON_VERSION) )\nGET_PYTHON_LIB_CMD=\"from distutils.sysconfig import get_python_lib; print (get_python_lib())\"\nLIB_VIRTUALENV_PATH=$(python -c \"$GET_PYTHON_LIB_CMD\")\nLIB_SYSTEM_PATH=$(${VAR[1]} -c \"$GET_PYTHON_LIB_CMD\")\n \nfor LIB in ${LIBS[@]}\ndo\n# Make each library specified in LIBS available in our current virtual env\nln -s $LIB_SYSTEM_PATH/${LIB} $LIB_VIRTUALENV_PATH/${LIB}\ndone",
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Other interesting modules\n\n matplotlib\n\n pip install matplotlib\n\n scikits\n\n pip install scikit-learn\n pip install scikit-image\n\n Pandas\n\n pip install numexpr\n pip install h5py\n pip install tables\n\n If you have problems importing tables, you might need to download and compile hdf5 library:\n<http://www.hdfgroup.org/HDF5/release/obtainsrc.html>\n\n pip install pandas"
},
{
"cell_type": "markdown",
"metadata": {},
"source": " statsmodels\n\n pip install patsy\n pip install statsmodels\n\n pymc\n\n pip install pymc"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Speed up execution\n\n bottleneck\n\n pip install bottleneck\n\n cythongsl\n\n pip install cythongsl"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### Neuroscience tools:\n\n Nibabel\n \n pip install nibabel\n \n \n Nipy* Dependencies:\n \n pip install sphinx sympy networkx traits \n \n pip install nipy\n\n pip install nipype dipy nitime\n\n\n(\\*) These tools only work on Python 2.* (in time of writing Dec 13th 2013):"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "### References\n\n 1. <http://www.cs.dartmouth.edu/~nfoti/blog/blog/2012/07/17/setting-up-virtualenv-for-data-analysis-on-osx/>\n\n 2. <http://calvinx.com/2012/11/03/ipython-qtconsole/>"
}
],
"metadata": {}
}
]
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment