I started to move along with using python 3, I want my python shell for to be working properly. As many of us must be aware, Python Shell is not really a very interactive prompt and most of the time, while I am working with Python, I tend to install Ipython as an alternative to work more flexibly with Python Shell.
When I downloaded and installed python3. I do not get ipython, this needs to be installed separately.
pip3 install ipython3 didn’t came of much help.
As, I am having multiple versions of python running on to my system, one is the native python version
2.7.11 which by default came with my OS, other python version
3.5.1 which I had explicity downloaded for using python3.
Googling around did helped much either, and the solution was pretty simple for implementation so I am documenting here in case anyone needs a quick help.
$ which ipython /usr/local/bin/ipython $ which python3 /usr/local/bin/python3 cp /usr/local/bin/ipython /usr/local/bin/ipython3
edit the ipython3 file.
#!/usr/local/bin/python # -*- coding: utf-8 -*- import re import sys from IPython import start_ipython if __name__ == '__main__': sys.argv = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv) sys.exit(start_ipython())
Change the shebang which is
Save the file.
run ipython3, I am assuming
/usr/local/bin is in your system path.
$ ipython Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) Type "copyright", "credits" or "license" for more information. IPython 4.2.0 -- 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. In :
What we basically did, was copied the original ipython file which was being used by python version 2 and ensured that to work with python3 by changing its shebang line, which tells ipython to use the desired python version. In case, if you do not already have ipython installed then
pip install ipython will just work, post your python 3 installation.
Though this is a quick hack, but really not an ideal solution.
Try and use virtual environment in case of multiple python installations.