Monday, 5 September 2016

Running both version of Python on Notebooks


Some time you wan to run both the Python Kernel to work on iPython Notebook.

Assuming that you have Anaconda (Python + Jupyter Notebook + Data Science Library).
For those are amateur like me
1. Download the Anaconda Installer from
     Windows: - https://www.continuum.io/downloads#windows
     OS X: - https://www.continuum.io/downloads#osx
     Linux: - https://www.continuum.io/downloads#linux



2. This installer will install the Python 3 + Jupyter Notebook on your System.

3. To access your Notebook you need to open your Terminal/Shell
and type
> jupyter notebook
NOTE: - Some people might try with "ipython notebook" but this command is soon going to be deprecated from the Conda Package.

4. Open the anaconda shell that has also been installed with the default anaconda package.

5. Type
conda create -n py27 python=2.7 ipykernel

6. This will create a Python 2.7 Virtual Environment named py27 in the envs folder of Anaconda.

7. You need to activate this Python Environment
For windows
py27\Scripts\activate
For Linux\Mac
source py27/bin/activate

8.  Now, we need to install the ipython kernel for Python 2.7
cd py27
python -m pip install ipykernel
NOTE: - Make sure that you are using the Python 2.7 right now

9. Now install it for the User
python -m ipykernel install --user
This command will place the ipykernel of python 2.7 in Jupyter Notebook's Kernel folder

10. Open your notebook and you would see both Python Kernels.

Enjoy :)

No comments:

Post a Comment