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
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.
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Python,
- Python: Convert Date to DateTime
- How to sort a List using Lambda in Python
- Python matplotlib segmentation fault: 11 macOS Big Sur
- What is Terminal Velocity and its Formula? How to calculate it programmatically?
- How to install Python 3.11 on Mac
- How to flatten a nested list in Python
- Python: Pandas Merge DataFrames on Index Example
- How to Run all Cells at Once Jupyter Notebook
- Python - Convert float to String
- How to add borders to tkinter label text
- How to Exit a Loop in Python Code
- [Python] Fix: ValueError: All arrays must be of the same length
- Sorting an array using Bubble Sort in Python Programming
- How to Unzip a file using Python
- Python: Merge DataFrames Pandas Outer Join Example
- Change label (text) color in tkinter
- Convert Float to String in Python
- Fix: fatal error: No such file or directory compilation terminated
- Python: Access index/counter of a for loop iteration
- Import Other Python Files Examples
- How to install Anaconda on Mac (M1/M2 Mac)
- Python Regular Expression to Find All Matches in List
- How to Read a binary File with Python
- How to disable warnings while Python file execution
- Know current Python Version
More Posts:
- How to change the KeyMap in Android Studio - Android-Studio
- How to delete a file using PowerShell [Windows/macOS] - Powershell
- M1/M2 Mac VirtualBox Unsupported hardware architecture detected! - MacOS
- [Docker M1/M2 Mac] qemu-x86_64: Could not open /lib64/ld-linux-x86-64.so.2: No such file or directory AWS CLI - Docker
- wget Command on macOS Terminal - MacOS
- Android Parsing Data for android-L failed Unsupported major.minor version 51.0 Error - Android
- [Fix] java: integer number too large compilation error - Java
- Setting up Java JUnit Project with Eclipse + Maven Example - Java