Reputation: 8074
The python version is 2.7.6 but when I install IPython
sudo pip install ipython
ipython it points to python 3.4.0. This leads to many syntax errors in modules that I commonly use due to python 3.x incompatibility.
I try editing the first line of the script /usr/local/bin/ipython:
#!/usr/bin/python3.4
becomes
#!/usr/bin/python
But then I get an error:
ImportError: No module named IPython
How can I get Ipython and my default python version (2.7.6) to work together?
Upvotes: 7
Views: 4061
Reputation: 475
In case you want to install Ipython for lower version of python you should check the compatibility.
If you simply try to install Ipython with the below command, there is a chance you end up installing the latest version of Ipython. Which has the compatibility issue which varies version to version.
$ pip install Ipython
Best solution would be to find the compatible version of Ipython from the below link. Ipython release history
For example Python 2.X supports Ipython below 5.X. It will be good to install
$ pip install ipython==4.2.1
Upvotes: 1
Reputation: 180522
Use ipython2
to start a ipython2 shell, if you need to install for python2 use pip2 install ipython
. pip
obviously points to python3 on your system so specifying pip2
will install ipython for python2.
Whatever the shebang points to will mean typing just ipython
will start a shell for that version of python so if you had #!/usr/bin/python3.4
then ipython
will start an ipython3 shell and vice-versa. Unless you have Ipython actually installed for python2 then changing the shebang won't do anything but error.
Upvotes: 3