0

I'm attempting to install ipython on a CentOS 6.5 box using pip, but I get an error because it is attempting to use python 2.6 instead of 2.7.

By default, I'm running python 2.6

$ python -V
Python 2.6.6

Which is located in /usr/bin/python

$ which python
/usr/bin/python

I've also installed python 2.7 and it is located in usr/local/bin/

$ which python2.7
/usr/local/bin/python2.7

I would like to install the latest version of ipython, and I'm using pip to do this.

$ sudo pip install ipython

Downloading/unpacking ipython
Downloading ipython-2.2.0.tar.gz (11.9MB): 11.9MB downloaded
Running setup.py (path:/tmp/pip_build_root/ipython/setup.py) egg_info for package ipython
ERROR: IPython requires Python version 2.7 or 3.3 or above.
Complete output from command python setup.py egg_info:
ERROR: IPython requires Python version 2.7 or 3.3 or above.

I can see that the setup.py script for ipython is determining the active version here:

v = sys.version_info

if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
    error = "ERROR: IPython requires Python version 2.7 or 3.3 or above."
    print(error, file=sys.stderr)
    sys.exit(1)

PY3 = (sys.version_info[0] >= 3)

How can I override the version that pip is assessing by default? Should I make a symbolic link to the python 2.7 in /usr/local/bin? Simply updating my bash profile with an alias for python at /usr/local/bin/python2.7 does not do the trick. Thanks.

1
  • 1
    pip will run with the version of Python in which pip itself is installed. So, to use pip for Python 2.7, install it in that version of Python. If you're using the pip provided by your distro (/usr/bin/pip), it will be for the Python provided by your distro. Commented Sep 21, 2014 at 5:04

1 Answer 1

1

If you're using virtualenv, you can use the -p switch when creating the environment and it will understand you want that version of python:

virtualenv -p /usr/local/bin/python2.7 ~/.virtualenvs/venv

Will create a virtualenv venv under ~/.virtuenvs with /usr/local/bin/python2.7 copied to ~/.virtualenvs/venv/bin/python for the python interpreter. The line on top of all scripts is similarly going to be #~/.virtualenvs/venv/bin/python . If you still have problems, do leave a comment.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm working through this now: virtualenv -p /usr/local/bin/python2.7 ~/.virtualenvs/venv Running virtualenv with interpreter /usr/local/bin/python2.7 Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/virtualenv.py", line 17, in <module> import zlib ImportError: No module named zlib
zlib is a core library in 2.7, it should be found.
Odd because if I open a new python2.7 interpreter and import zlib, there is no issue finding the module. For now, I've just found an older version of ipython and installed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.