If you are a Python hacker, most likely you will be using a virtualenv for your development environment, you are probably an iPython user. Unluckily, IPython doesn’t pick the virtualenv paths by default and you will have to tweak it a little bit to make it work. Basically, this a slightly tweaked version of this article but tailored for the recent version of IPython 0.11.
You simply need to drop this snippet of code into the iPython configuration directory as illustrated below so that IPython can add the virtualenv paths.
import site
from os import environ
from os.path import join
from sys import version_info
if 'VIRTUAL_ENV' in environ:
virtual_env = join(environ.get('VIRTUAL_ENV'),
'lib',
'python%d.%d' % version_info[:2],
'site-packages')
site.addsitedir(virtual_env)
print 'Using Virtualenv =>', virtual_env
del virtual_env
del site, environ, join, version_info
Drop that snippet into a file named “ipython_config.py” in the following path if you are using Mac OS X or Linux (tested on Ubuntu natty):
~/.ipython/profile_default/ipython_config.py
Happy Hacking!










by AlSayed Gamal
27 Sep 2011 at 21:46
Testing and will tell you
Thanks in advance
by Thomas
29 Sep 2011 at 01:48
If you ensure that your IPython startup script has the hashbang line:
#!/usr/bin/env python
(rather than #!/usr/bin/python), it should pick up on your virtualenv automatically (at least on Mac & Linux). Unfortunately, this line seems to depend on how it was installed, so we can’t set it for everyone using IPython.
by Robert
25 Oct 2011 at 02:25
This is great! It took me a while to find a proper set of instructions for IPython 0.11, so thanks for putting this out there!
by Jeffrey4l
13 Dec 2011 at 02:27
Cool! It works. Thanks guys.
by AlSayed Gamal
13 Dec 2011 at 12:52
I forgot to reply this we used it and helped me specially when we deployed our application on heroku
Thanks
by scott
16 Jan 2012 at 18:34
I was tearing my hair out trying to figure out why ipython wasn’t picking up module installs. Thank you for the tip.
by Andrew
20 Jan 2012 at 23:02
It worked great. Thnx