I use IPython notebooks and would like to be able to select to create a 2.x or 3.x python notebook in IPython.
I initially had Anaconda. With Anaconda a global envi
Use sudo pip3 install jupyter
for installing jupyter for python3 and sudo pip install jupyter
for installing jupyter notebook for python2. Then, you can call ipython kernel install
command to enable both types of notebook to choose from in jupyter notebook.
The idea here is to install multiple ipython
kernels. Here are instructions for anaconda. If you are not using anaconda, I recently added instructions using pure virtualenvs.
Since version 4.1.0, anaconda includes a special package nb_conda_kernels
that detects conda environments with notebook kernels and automatically registers them. This makes using a new python version as easy as creating new conda environments:
conda create -n py27 python=2.7 ipykernel
conda create -n py36 python=3.6 ipykernel
After a restart of jupyter notebook, the new kernels are available over the graphical interface. Please note that new packages have to be explicitly installed into the new environments. The Managing environments section in conda's docs provides further information.
Users who do not want to use nb_conda_kernels
or still use older versions of anaconda can use the following steps to manually register ipython kernels.
configure the python2.7
environment:
conda create -n py27 python=2.7
conda activate py27
conda install notebook ipykernel
ipython kernel install --user
configure the python3.6
environment:
conda create -n py36 python=3.6
conda activate py36
conda install notebook ipykernel
ipython kernel install --user
After that you should be able to choose between python2
and python3
when creating a new notebook in the interface.
Additionally you can pass the --name
and --display-name
options to ipython kernel install
if you want to change the names of your kernels. See ipython kernel install --help
for more informations.
With a current version of the Notebook/Jupyter, you can create a Python3 kernel. After starting a new notebook application from the command line with Python 2 you should see an entry „Python 3“ in the dropdown menu „New“. This gives you a notebook that uses Python 3. So you can have two notebooks side-by-side with different Python versions.
mkdir -p ~/.ipython/kernels/python3
Create this file ~/.ipython/kernels/python3/kernel.json
with this content:
{
"display_name": "IPython (Python 3)",
"language": "python",
"argv": [
"python3",
"-c", "from IPython.kernel.zmq.kernelapp import main; main()",
"-f", "{connection_file}"
],
"codemirror_mode": {
"version": 2,
"name": "ipython"
}
}
Restart the notebook server.
$ pip install --user ipykernel
$ python -m ipykernel install --user --name=test2
Following are the steps to add the python2 kernel to jupyter notebook::
open a terminal and create a new python 2 environment: conda create -n py27 python=2.7
activate the environment: Linux source activate py27
or windows activate py27
install the kernel in the env: conda install notebook ipykernel
install the kernel for outside the env: ipython kernel install --user
close the env: source deactivate
Although a late answer hope someone finds it useful :p
I looked at this excellent info and then wondered, since
if PyCharm would use
ANSWER: Yes!
P.S. i have Python Launcher for Windows installed as well.