Bite code
Bite code

Reputation: 597381

How to force iPython to use an older version of Python?

I am running an Ubuntu 8.10, using Python 2.5 out of the box. This is fine from the system point of view, but I need Python2.4 since I dev on Zope / Plone.

Well, installing python2.4 is no challenge, but I can't find a (clean) way to make iPython use it : no option in the man nor in the config file.

Before, there was a ipython2.4 package but it is deprecated.

Upvotes: 10

Views: 10810

Answers (6)

Assombrance Andreson
Assombrance Andreson

Reputation: 461

To complement on @Peter's answer, I might add that the ipython "executable" you run are simply python script that launch the ipython shell. So a solution that worked for me was to change the python version that runs that script:

$ cp ipython ipython3
$ nano ipython3

Here is what the script looks like:

#!/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())

You can now replace this first line with your correct version of python, for example, you may wan to use python 3:

$ which python3
/usr/bin/python3

so you would simply replace /usr/bin/python by /usr/bin/python3 in your newly created ipython3 file!

Upvotes: 0

Peter
Peter

Reputation: 577

I find the simplest way to specify which python version to use is to explicitly call the ipython script using that version. To do this, you may need to know the path to the ipython script, which you can find by running which ipython. Then simply run python <path-to-ipython> to start ipython.

Upvotes: 1

Pol Alvarez Vecino
Pol Alvarez Vecino

Reputation: 187

Actually you can run the ipython with the python version you like:

python2.7 ipython
python3 ipython

This is easiest solution for me and avoids virtual env setup for one-shot trials.

Upvotes: 0

atupal
atupal

Reputation: 17240

You can just:

$ python2.4 setup.py install --prefix=$HOME/usr
$ python2.5 setup.py install --prefix=$HOME/usr

or

alias ip4 "python2.4 $HOME/usr/bin/ipython"
alias ip5 "python2.5 $HOME/usr/bin/ipython"

fyi

Upvotes: 0

idbrii
idbrii

Reputation: 11966

I'm using Ubuntu 10.10 and there's only on ipython installed. (There's also only one python available, but I got an older version with the deadsnakes ppa.)

To get ipython2.5, I installed ipython from your virtualenv:

virtualenv --python=/usr/bin/python2.5 project_name
source project_name/bin/activate
pip install ipython

Then the ipython version should match the python passed into virtualenv with --python.

Upvotes: 4

Bite code
Bite code

Reputation: 597381

Ok, I answer my own question : I'm dumb :-)

ls /usr/bin/ipython*
/usr/bin/ipython  /usr/bin/ipython2.4  /usr/bin/ipython2.5

Now it's built-in...

Upvotes: 11

Related Questions