How to fix different version of Jupyter notebook on terminal and Anaconda.

Hi,
I am new to the forum. I have an issue with having different jupyter notebook running depending on how I start it. I have a MAC and tend to use data science and scraping libraries and originally I installed my jupyter notebook via Anaconda and everything worked fine.

Recently, I tried adding nbextension and it didn’t work using conda forge method, and I installed it via pip. Then I noticed I have two different jupyter running if I start via the terminal vs. via Anaconda Navigator.

I am not sure why this is and how to fix it. Ideally I’d like to go back to Anaconda version since I use the libraries there more. Is there a PATH or a setting I need to do to do that?

Right now, if I do pip (just showing which jupyter NB I have)
(base) Frances-MAC:~ francesho$ pip list
Package Version


ipykernel 6.4.1
ipython 7.27.0
ipython-genutils 0.2.0
ipywidgets 7.6.4
jedi 0.18.0
Jinja2 3.0.1
jsonschema 3.2.0
jupyter 1.0.0
jupyter-client 7.0.2
jupyter-console 6.4.0
jupyter-contrib-core 0.3.3
jupyter-contrib-nbextensions 0.5.1
jupyter-core 4.7.1
jupyter-highlight-selected-word 0.2.0
jupyter-latex-envs 1.4.6
jupyter-nbextensions-configurator 0.4.1
jupyterlab-pygments 0.1.2
jupyterlab-widgets 1.0.1

If I run jupyter on the terminal. I get.
(base) Frances-MAC:~ francesho$ jupyter notebook
[I 11:53:50.602 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 11:53:50.604 NotebookApp] Serving notebooks from local directory: /Users/francesho
[I 11:53:50.604 NotebookApp] Jupyter Notebook 6.4.3 is running at:
[I 11:53:50.605 NotebookApp] http://localhost:8888/?token=de7368b7d11d5d3274ef74babf30ae4676053d6911ed7445
[I 11:53:50.605 NotebookApp] or http://127.0.0.1:8888/?token=de7368b7d11d5d3274ef74babf30ae4676053d6911ed7445
[I 11:53:50.605 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:53:50.629 NotebookApp]

To access the notebook, open this file in a browser:
    file:///Users/francesho/Library/Jupyter/runtime/nbserver-1727-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/?token=de7368b7d11d5d3274ef74babf30ae4676053d6911ed7445
 or http://127.0.0.1:8888/?token=de7368b7d11d5d3274ef74babf30ae4676053d6911ed7445

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
return _iterencode(o, 0)

If I launch jupyter via Anaconda Navigator, it is different. I get the following on my terminal.

/Users/francesho/opt/anaconda3/bin/jupyter_mac.command ; exit;
(base) Frances-MAC:~ francesho$ /Users/francesho/opt/anaconda3/bin/jupyter_mac.command ; exit;
[I 11:55:37.413 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found
[I 11:55:38.952 NotebookApp] The port 8888 is already in use, trying another port.
[W 11:55:38.955 NotebookApp] Error loading server extension jupyter_nbextensions_configurator
Traceback (most recent call last):
File “/Users/francesho/opt/anaconda3/lib/python3.8/site-packages/notebook/notebookapp.py”, line 2033, in init_server_extensions
mod = importlib.import_module(modulename)
File “/Users/francesho/opt/anaconda3/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘jupyter_nbextensions_configurator’
[W 2021-09-19 11:55:39.872 LabApp] Config option kernel_spec_manager_class not recognized by LabApp.
[W 2021-09-19 11:55:39.877 LabApp] Config option kernel_spec_manager_class not recognized by LabApp.
[I 2021-09-19 11:55:39.887 LabApp] JupyterLab extension loaded from /Users/francesho/opt/anaconda3/lib/python3.8/site-packages/jupyterlab
[I 2021-09-19 11:55:39.887 LabApp] JupyterLab application directory is /Users/francesho/opt/anaconda3/share/jupyter/lab
[I 11:55:39.912 NotebookApp] [nb_conda] enabled
[I 11:55:39.913 NotebookApp] Serving notebooks from local directory: /Users/francesho
[I 11:55:39.913 NotebookApp] Jupyter Notebook 6.3.0 is running at:
[I 11:55:39.913 NotebookApp] http://localhost:8889/?token=7ec02e257c4475e1cfd7bee400164f076f4b6149a2c70975
[I 11:55:39.913 NotebookApp] or http://127.0.0.1:8889/?token=7ec02e257c4475e1cfd7bee400164f076f4b6149a2c70975
[I 11:55:39.913 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:55:39.935 NotebookApp]

To access the notebook, open this file in a browser:
    file:///Users/francesho/Library/Jupyter/runtime/nbserver-1826-open.html
Or copy and paste one of these URLs:
    http://localhost:8889/?token=7ec02e257c4475e1cfd7bee400164f076f4b6149a2c70975
 or http://127.0.0.1:8889/?token=7ec02e257c4475e1cfd7bee400164f076f4b6149a2c70975

[W 11:55:42.729 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/tree_tab/main.js?v=20210919115537 (::1) 18.010000ms referer=http://localhost:8889/tree

Noticed that one jupyter notebook can run nbextension and the other I am getting error message. I realized that once I go back to Anaconda version of jupyter, I should fix that error but that is for next time.

Thanks!

I don’t use MacOS, or Anaconda, but it looks to me as though you’re using a different pip than the pip installed in your Anaconda environment. By the way, you can use 3+ backticks to embed code on Discourse, because it uses Markdown.

Some context:
Anaconda installs its own Python interpreter (as well as other packages), because it is effectively a stand-alone multi-platform package manager (using conda/conda-forge). In addition, conda supports environments, which are similar in concept to the Python virtual environments which sandbox Python interpreters from one-another. This means that you invoke different binaries depending upon which environment is active when you run a command in your shell.

I can’t tell whether you’re using two different (conda) environments. A good way to check is to run which pip inside the Jupyter Notebook (with !which pip) and in the Terminal (with which pip) just to check which binaries are being used in each case. Perhaps you can report back with your findings?

2 Likes

Here are the pip printout

From Anaconda
/Users/francesho/opt/anaconda3/bin/pip

From terminal,
/Users/francesho/opt/anaconda3/bin/pip
Now they are the same, so my problem is solved.

But yesterday, when I ran which jupyter on terminal it was
/Library/Frameworks/Python.framework/Versions/3.8/bin/jupyter
Today it is
/Users/francesho/opt/anaconda3/bin/jupyter

So it seems both the terminal and Anaconda is looking at the same jupyter and my problem is solved However, I am not quite sure how or why.