jupyter / jupyter/notebook

Jupyter Notebook is loading incorrect Python kernel

Open
#2,563 43 comments 19 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I am on OSX Sierra (10.12.5), and am using Jupyter Notebook v 4.3.0. I have installed both Python2 and Python3 using Homebrew, and both kernels for Jupyter Notebook. Upon opening the notebook to use Python3 kernel, I find that it still uses Python2.

I might be missing something obvious in my installation, but I can't seem to figure out what it is.

## Detailed Description

### Installation:
I installed both Python2 and Python3 using Homebrew, and Jupyter Notebook on my system thus:
`brew install python3`
`pip3 install --upgrade pip3 setuptools wheel`
`pip3 install jupyter`

I ran all analogous commands for Python2 as well.

### Configuration:
I generated the config file using
`jupyter notebook --generate-config`, and the only configurations I have "enabled" in my config file are:
`c.NotebookApp.browser = u'safari'`
`c.NotebookApp.password = 'sha1:somepwd'`

### Both kernels installed:

Both kernels seem to be visible to kernelspec:
```
jupyter kernelspec list
Available kernels:
python2 /usr/local/share/jupyter/kernels/python2
python3 /usr/local/share/jupyter/kernels/python3
```
Both kernels are also available as options when I start execute `jupyter notebook`:
![screen shot 2017-06-08 at 1 49 24 pm](https://user-images.githubusercontent.com/26838740/26942848-8e083c92-4c51-11e7-8c0e-6df6be7243fb.png)

As an additional check, `pip list` and `pip3 list` both include `ipykernel`.

### Problem:

When I opened a new notebook using **Python3** kernel, none of the packages I installed using `pip3` were recognized when I used `import`. Furthermore, `sys.path` returns path to Python2:

screen shot 2017-06-08 at 1 59 32 pm

When I run `print "Hello World"`, it gives me a successful output (which is true in Python2, but should throw an error in Python3).

*However*, when I use the (depreciated) command `ipython3 notebook`, things work as expected:
screen shot 2017-06-08 at 1 58 29 pm
and all my Python3 packages are successfully recognized.

It doesn't seem to be the biggest deal breaker, as I can continue working with `ipython3 notebook`, but I wonder what I am missing that causes `jupyter notebook` to not load Python3.

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior using the listed Homebrew, pip, and pip3 commands, then compare `jupyter kernelspec list`, a notebook started with `jupyter notebook`, and one started with `ipython3 notebook`. Check whether selecting Python3 actually uses the Python3 kernel and can import packages installed with pip3; the issue is resolved when the selected kernel reports Python3 paths and behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.