> For the complete documentation index, see [llms.txt](https://wiki.philmohun.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.philmohun.com/draft/technology/jupyter.md).

# Jupyter

## Useful Commands

```
!which python; python -V # check python version
```

## Common Issues & Troubleshooting

### ModuleNotFoundError

![](/files/-LdsV0oAS4OKSBBkCNMz)

Jupyter Notebook tends to create path issues that disagree with the python path run locally. To fix this, I use the following troubleshooting methods:

#### Kernel.json

In the terminal:

```
# check Jupyter path
$ which -a jupyter
/usr/local/bin/jupyter # sample output

# check default python path
$ which -a python
/usr/bin/python

# check python3 path
$ which -a python3
/usr/local/bin/python3
```

If there is disagreement between the paths (as shown above), you can redirect the Jupyter kernel to point at the desired directory.

```
# identify where Jupyter stores kernel information
$ jupyter kernselspec list
Available kernels:
  python3    /usr/local/share/jupyter/kernels/python3
```

Navigate to the `/kernels` directory and locate `kernel.json`

Inside:

```
{
 "argv": ["python3", 
 "-m", 
 "IPython.kernel",
 "-f", 
 "{connection_file}"],
 "display_name": "Python 3",
 "language": "python"
}
```

Where it lists "python3" change it to your python path where the libraries are being installed. For example:

```
{
 "argv": [
  "/usr/local/opt/python/bin/python3.7",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}
```

The python3 kernel should now be pointing at the correct directory.&#x20;

#### iPython Kernel Install

Navigate to the repository where the notebook files live and follow the recommendation in [this issue from the Jupyter Github.](https://github.com/jupyter/notebook/issues/2563)

> `ipython kernel install`

Check `kernel.json` to confirm that the path has been updated and that the path matches.

To confirm that your Jupyter notebook is running the same version of python:

In Jupyter notebook:

```
import sys
sys.executable
'/usr/local/opt/python/bin/python3.7' # this is from kernel.json
```

In the terminal:

```
$ python3
import sys
sys.executable
'/usr/local/opt/python/bin/python3.7'
'/Library/Frameworks/Python.framework/Versions/3.7/bin/python3'
```

Oops! If they don't match, then use the executable path from your locally installed python version to update `kernel.json`

Restart the notebook to see results.&#x20;

#### Uninstall Jupyter

If none of the above methods worked, try uninstalling Jupyter.&#x20;

```
pip uninstall jupyter
pip install jupyter
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.philmohun.com/draft/technology/jupyter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
