edit: I found the answer, mods please delete this if you want, or leave it for posterity. It turns out this may be a pretty common issue for people migrating to pyenv so it might even be good to put it in the documentation.
This is embarrassing. You know how sometimes you find the answer right after you ask the question. This solved my issue. I deleted the directory of the python3 listing in “jupyter kernelspec list”. After I did this, I noticed it changed the python3 listing from what it was (something vaguely like ~/Library/Jupyter/kernels/python3) to ~/.pyenv/versions/3.8.5/share/jupyter/kernels/python3.
---------------------------------------------------------------------------------------
Hi, I used to be able to use jupyter notebook and jupyter lab in the past, but then I must have done something to my Python setup (relevant xkcd), and now it won’t work at all . I’ve been trying to fix it on and off for months, and I really need to get it working again.
I tried deleting all my python environments and reinstalling using “pyenv” to manage everything, including a reinstallation of jupyter, but it’s still not working.
The full error message I receive when opening up a notebook is below:
[I 17:23:00.297 LabApp] JupyterLab extension loaded from /Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/jupyterlab
[I 17:23:00.297 LabApp] JupyterLab application directory is /Users/<my_username>/.pyenv/versions/3.8.5/share/jupyter/lab
[I 17:23:00.300 LabApp] Serving notebooks from local directory: /Users/<my_username>/PythonLocalProject
[I 17:23:00.300 LabApp] Jupyter Notebook 6.1.4 is running at:
[I 17:23:00.300 LabApp] http://localhost:8888/?token=<some token dunno if its sensitive info>
[I 17:23:00.300 LabApp] or http://127.0.0.1:8888/?token=<some token dunno if its sensitive info>
[I 17:23:00.300 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:23:00.318 LabApp]
To access the notebook, open this file in a browser:
file:///Users/<my_username>/Library/Jupyter/runtime/nbserver-59518-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=<some token dunno if its sensitive info>
or http://127.0.0.1:8888/?token=<some token dunno if its sensitive info>
[I 17:23:04.520 LabApp] Build is up to date
[E 17:23:15.965 LabApp] Failed to run command:
['/Users/<my_username>/.pyenv/versions/jupyter3/bin/python', '-m', 'ipykernel_launcher', '-f', '/Users/<my_username>/Library/Jupyter/runtime/kernel-98b1fc46-cf81-4195-aaef-c5a8c59a5cff.json']
PATH='/Users/<my_username>/.pyenv/versions/3.8.5/bin:/usr/local/Cellar/pyenv/1.2.21/libexec:/usr/local/Cellar/pyenv/1.2.21/plugins/python-build/bin:/usr/local/Cellar/pyenv-virtualenv/1.1.5/shims:/Users/<my_username>/.pyenv/shims:/Users/<my_username>/.pyenv/shims:/usr/local/sbin:/Users/<my_username>/.emacs.d/bin:/Users/<my_username>/bin:/usr/local/bin:/usr/local/sbin:/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin'
with kwargs:
{'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': '/Users/<my_username>/PythonLocalProject', 'start_new_session': True}
[E 17:23:15.968 LabApp] Uncaught exception POST /api/sessions?1608272595926 (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions?1608272595926', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/web.py", line 1703, in _execute
result = await result
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/notebook/services/sessions/handlers.py", line 69, in post
model = yield maybe_future(
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/notebook/services/sessions/sessionmanager.py", line 100, in start_kernel_for_session
kernel_id = yield maybe_future(
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/notebook/services/kernels/kernelmanager.py", line 176, in start_kernel
kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/jupyter_client/multikernelmanager.py", line 185, in start_kernel
km.start_kernel(**kwargs)
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/jupyter_client/manager.py", line 313, in start_kernel
self.kernel = self._launch_kernel(kernel_cmd, **kw)
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/jupyter_client/manager.py", line 220, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/site-packages/jupyter_client/launcher.py", line 131, in launch_kernel
proc = Popen(cmd, **kwargs)
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/<my_username>/.pyenv/versions/3.8.5/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<my_username>/.pyenv/versions/jupyter3/bin/python'
[W 17:23:15.979 LabApp] Unhandled error
[E 17:23:15.980 LabApp] {
"Host": "localhost:8888",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:83.0) Gecko/20100101 Firefox/83.0",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate",
"Referer": "http://localhost:8888/lab/workspaces/auto-4",
"Content-Type": "text/plain;charset=UTF-8",
"Authorization": "<some token dunno if it's sensitive info>",
"X-Xsrftoken": "<some token dunno if its sensitive info>",
"Origin": "http://localhost:8888",
"Content-Length": "117",
"Dnt": "1",
"Connection": "keep-alive",
"Cookie": "<some cookie dunno if its sensitive info>";
"Pragma": "no-cache",
"Cache-Control": "no-cache"
}
[E 17:23:15.980 LabApp] 500 POST /api/sessions?1608272595926 (127.0.0.1) 50.34ms referer=http://localhost:8888/lab/workspaces/auto-4
[I 17:23:19.352 LabApp] interrupted
[C 17:23:19.558 LabApp] received signal 2, stopping
[I 17:23:19.560 LabApp] Shutting down 0 kernels
[I 17:23:19.560 LabApp] Shutting down 0 terminals
Also my jupter --path if that helps:
config:
/Users/<my_username>/.jupyter
/Users/<my_username>/.pyenv/versions/3.8.5/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/Users/<my_username>/Library/Jupyter
/Users/<my_username>/.pyenv/versions/3.8.5/share/jupyter
/usr/local/share/jupyter
/usr/share/jupyter
runtime:
/Users/<my_username>/Library/Jupyter/runtime
If anyone sees what’s wrong can you suggest a fix? Or even if there’s some way to revert everything relevant to ‘factory defaults’ so it’ll work. I’m using OSX Catalina btw. Thanks.