New version of iPython installed, but only old version can be used

(There is a similar question, so I intended to provide more information below that one but got my post deleted. So I'll ask my own question here.)

I installed the newest version of iPython by typingsudo -H pip install ipython

I confirmed the installed version is 3.1.0

> pip show ipython
---
Metadata-Version: 2.0
Name: ipython
Version: 3.1.0
Summary: IPython: Productive Interactive Computing
Home-page:
Author: The IPython Development Team
Author-email:
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: 

However, when I type ipython command and enter the program, the message is:

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

The only way the IPython 3.1.0 can be called is to type ipython in the directory /usr/local/lib/python2.7/dist-packages where pip installed it.

By comparing the help file in iPython, I confirmed they are indeed different versions (so not just displaying wrong version).

Typing which ipython would give /usr/local/bin/ipython, whose content is

#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from IPython import start_ipython
if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(start_ipython())

Weirdly, when I use pip uninstall ipython to remove ipython 3.1.0, the old 1.2.1 version (which I assume came with the system and caused the confusion) also disappeared.

1

1 Answer

I had a similar issue. It turned out that I had two versions of IPython installed, and running ipython in the command line was launching the older version.

To resolve this issue, I simply had to update my PATH variable in my /.bashrc (or /.zshrc if you're using zsh as your shell) file.

export PATH="/path_to_my_anaconda/anaconda/bin:$PATH"

Since this section is pre-pended to your original PATH, running ipython should now launch the ipython version that is in anaconda (which I wanted) rather than the vanilla installation.

After sourcing the /.bashrc file with the above line, running ipython from the command line started the version of IPython I wanted.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like