How to Make iPython Work in a virtualenv Virtual Environment

Tyler Tyler (304)
10 minutes

Trying to run iPython inside of a virtualenv virtual environment will likely result in this error:

WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.

This is a problem because my virtual environment is running Python 3.5, and iPython is using the system's Python 2.7.

Posted in these interests:
h/python67 guides

Make sure your virtual environment is activated. For this demo, mine is called py3.

workon py3

Now install iPython.

pip install iPython


pip3 install iPython

After running iPython you may still see the warning find that it's still trying to use Python 2.7. If so, look at Step 2.

From your bash shell, run:

hash -r

And try running iPython again.

When you've run iPython previously in a shell session, that command was cached. This command simply resets the cache. And now when you run:


It will refer to the version of iPython that you installed in your virtual environment.

You're now running iPython.

Get the latest edition of Python in just minutes.
Ash Ash (343)
6 minutes

If it's been a while since you first installed Python, it might be time to check out the latest edition: Python 3. It has plenty of cool new features from data classes to typing enhancements.