The Cranky Sysadmin A world of technology, fun, and ignorant rants.

April 24, 2015

Xubuntu 15.04 Emacs and Python Data Science Setup in Virtualenv

Filed under: Programming,System Administration — Cranky Sysadmin @ 1:20 pm

If you understand the title and want to see the instructions, see after the fold.

Ensure you have virtualenv and virtualenvwrapper installed

sudo apt-get install virtualenv virtualenvwrapper

Install the virtual environment. I like python3 so I set the python binary. This will setup an environment called “pythonds” you can call it what you like.

mkvirtualenv -p /usr/bin/python3.4 python3ds
workon python3ds

Run the following before installing matplotlib as per StackOverflow

sudo apt-get install libfreetype6-dev

This is required for part of ipython notebook

sudo apt-get install libzmq3-dev

And now install all of your packages in the virtual environment.

pip install -U setuptools pip
pip install numpy scipy ipython[all] pandas sympy scikit-learn csvkit matplotlib

Ensure that you have the virtualenvwrapper and ein packages installed in emacs
The ein github page has a nice summary of how to use it. Use the magic %pylab inline to get your nice inline images in emacs.

I don’t use the QT console for matplotlib or ipython. Here are some thoughts for getting it
running if you want QT in virtualenv.

for pyqt4 you need qt4 libs installed:

sudo apt-get install libqt4-dev libqtcore4 libqtgui4

then you need to manually build and install sip and pyqt4:
http://www.riverbankcomputing.com/software/sip/download
http://www.riverbankcomputing.com/software/pyqt/download
to configure sip, run the following in the sip source directory:

python configure.py --incdir=${VIRTUAL_ENV}/include
make
make install

and for pyqt4 run the same in its source directory

You’ll have to uninstall matplotlib and reinstall it with easy_install to use QT.
I haven’t figured out what magic causes this:

pip uninstall matplotlib
easy_install matplotlib

You may have to rebuild ipython as well, but I haven’t attempted that.

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Powered by WordPress