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?
Create a folder called startup if it's not already there. Add a new Python file called start.py. Put your favorite imports in this file. Launch IPython or a Jupyter Notebook and your favorite libraries will be automatically loaded every time!
To check the Python version in your Jupyter notebook, first import the python_version function with “ from platform import python_version “. Then call the function python_version() that returns a string with the version number running in your Jupyter notebook such as "3.7. 11" .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With