Mo Sander Mo Sander - 2 years ago 105
Python Question

calling ipython from a virtualenv

I understand that ipython is not virtualenv-aware and that the most logical solution to this is to install ipython in each virtualenv seperately using

pip install ipython

So far so good. One thing I noticed is that if the system-wide copy of ipython is called from within a virtualenv using
$> ipython
before ipython is installed under this virtualenv, subsequent
$> ipython
commands will continue to bring up the system-wide ipython copy.

On the other hand, if ipython is not called prior to installing it under a virtualenv
$> ipython
will bring up the newly installed copy.

What is the explanation for this?

It also makes me wonder if this behavior means I should expect some trouble down the way?

Thanks for your time!

Answer Source

alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"

This is a great way of always being sure that the ipython instance always belongs to the virtualenv's python version.

This works only on ipython >2.0.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download