Conda ValueError when trying to open jupyter notebook
conda
error
terminal
Getting ValueError when forgetting to add
condawhen trying to activate conda environment
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/bin/jupyter-notebook", line 10, in <module>
sys.exit(main())
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyter_core/application.py", line 283, in launch_instance
super().launch_instance(argv=argv, **kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/traitlets/config/application.py", line 1074, in launch_instance
app.initialize(argv)
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/traitlets/config/application.py", line 118, in inner
return method(app, *args, **kwargs)
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/notebook/notebookapp.py", line 2171, in initialize
self.init_webapp()
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/notebook/notebookapp.py", line 1779, in init_webapp
self.web_app = NotebookWebApplication(
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/notebook/notebookapp.py", line 178, in __init__
settings = self.init_settings(
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/notebook/notebookapp.py", line 316, in init_settings
nbextensions_path=jupyter_app.nbextensions_path,
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/notebook/notebookapp.py", line 1349, in nbextensions_path
from IPython.paths import get_ipython_dir
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/IPython/__init__.py", line 55, in <module>
from .terminal.embed import embed
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 31, in <module>
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
ValueError: source code string cannot contain null bytes
Steps to reproduce error
- Open terminal
- Activate your environment, here
myenv:
(base) activate myenv
- Open jupyter notebook
jupyter notebook
How to fix it
The error is because I did not specify conda when trying to activate environment. It should be:
(base) conda activate myenv
Why we get this error
When we do activate myenv, we are still in our base environment and not myenv. Perhaps some of the libraries required to open jupyter notebook is outdated in our base environment.