Fix: python3: Library/Developer/CommandLineTools/usr/bin/python3: No module named notebook (jupyter)


If you are trying to run a notebook in Terminal and you get an error "No module named notebook", you are missing the jupyter module.

% python3 -m notebook

/Library/Developer/CommandLineTools/usr/bin/python3: No module named notebook

Fix: No module named notebook error

Solution 1:
    • Open Terminal (or Command Line)
    • Run the following command to install to install jupyter

      pip3 install jupyter

    • Now you should be able to run the notebook
Solution 2:

    Do check which pip3 and python3 binaries are in use, it could be that there is a mismatch

    % which pip3
    /opt/homebrew/bin/pip3
    
     % which python3
    /usr/bin/python3

    As you may see using the which command, we have pip3 from homebrew package and python3 form usr/bin.

    Make sure to install jupyter package using brew command.

    brew install jupyter

    Setting an alias in .zshrc or .bashprofile would help to fix this issue.

    alias python3.10="/opt/homebrew/bin/python3.10"

% python3 -m notebook
[I 11:43:06.459 NotebookApp] Writing notebook server cookie secret to /Users/code2care/Library/Jupyter/runtime/notebook_cookie_secret

  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|
                       
Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[I 11:43:06.649 NotebookApp] Serving notebooks from local directory: /opt/homebrew/bin
[I 11:43:06.649 NotebookApp] Jupyter Notebook 6.5.3 is running at:
[I 11:43:06.649 NotebookApp] http://localhost:8888/?token=028705476147dd17b34a1f0699eda8efb5dc9184a16a0f77
[I 11:43:06.649 NotebookApp]  or http://127.0.0.1:8888/?token=028705476147dd17b34a1f0699eda8efb5dc9184a16a0f77
[I 11:43:06.649 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

    To access the notebook, open this file in a browser:
        file:///Users/code2care/Library/Jupyter/runtime/nbserver-6362-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=028705476147dd17b34a1f0699eda8efb5dc9184a16a0f77
     or http://127.0.0.1:8888/?token=028705476147dd17b34a1f0699eda8efb5dc9184a16a0f77
[W 11:43:08.224 NotebookApp] 404 GET /apple-touch-icon-precomposed.png (::1) 15.820000ms referer=None
[W 11:43:08.232 NotebookApp] 404 GET /apple-touch-icon.png (::1) 2.090000ms referer=None
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Python Jupyter error fixed - No module named notebook

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap