I use Jupyter notebook in a browser for Python programming, I have installed Anaconda (Python 3.5). But I'm quite sure that Jupyter in running my python commands with the native python interpreter and not with anaconda. How can I change it and use Anaconda as interpreter ?
Thanks!
Ubuntu 16.10 -- Anaconda3
Assuming you have the wrong backend system you can change the backend
kernel
by creating a new or editing the existingkernel.json
in thekernels
folder of your jupyter data pathjupyter --paths
. You can have multiple kernels (R, Python2, Python3 (+virtualenvs), Haskell), e.g. you can create anAnaconda
specific kernel:Should create a new kernel:
<jupyter-data-dir>/kernels/anaconda/kernel.json
You need to ensure
ipykernel
package is installed in the anaconda distribution.This way you can just switch between kernels and have different notebooks using different kernels.
from platform import python_version print(python_version())
This will give you the exact version of python running your script. eg output:
3.6.5
Seen below :- output when i run JupyterNotebook outside a CONDA venv
Seen below when i run same JupyterNoteBook within a CONDA Venv created with command --
in my Jupyter Notebook it prints :-
also if you already have various VENV's created with different versions of Python you switch to the desired Kernel by choosing KERNEL >> CHANGE KERNEL from within the JupyterNotebook menu... JupyterNotebookScreencapture
Also to install ipykernel within an existing CONDA Virtual Environment -
http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments
Source --- https://github.com/jupyter/notebook/issues/1524
Install the IPython kernel spec.
optional arguments: -h, --help show this help message and exit --user Install for the current user instead of system-wide --name NAME Specify a name for the kernelspec. This is needed to have multiple IPython kernels at the same time. --display-name DISPLAY_NAME Specify the display name for the kernelspec. This is helpful when you have multiple IPython kernels. --profile PROFILE Specify an IPython profile to load. This can be used to create custom versions of the kernel. --prefix PREFIX Specify an install prefix for the kernelspec. This is needed to install into a non-default location, such as a conda/virtual-env. --sys-prefix Install to Python's sys.prefix. Shorthand for --prefix='/Users/bussonniermatthias/anaconda'. For use in conda/virtual-envs.
will give you the interpreter. You can select the interpreter you want when you create a new notebook. Make sure the path to your anaconda interpreter is added to your path (somewhere in your bashrc/bash_profile most likely).
For example I have the following line in my .bash_profile :