我有通过Homebrew安装的Python版本3.6.5_1
和3.7.0
。
jupyter
需要python 3.6
才能启动。如果我切换到python 3.7
,它将无法启动。
启动后,它无法启动内核。出现此错误:
Traceback (most recent call last):
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/web.py", line 1543, in _execute
result = yield result
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/notebook/services/sessions/handlers.py", line 73, in post
type=mtype))
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/vendor/lib/python3.6/site-packages/tornado/gen.py", line 315, in wrapper
yielded = next(result)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 148, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/jupyter_client/manager.py", line 259, in start_kernel
**kw)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "/usr/local/Cellar/jupyter/1.0.0_4/libexec/lib/python3.6/site-packages/jupyter_client/launcher.py", line 128, in launch_kernel
proc = Popen(cmd, **kwargs)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/opt/python/bin/python3.7': '/usr/local/opt/python/bin/python3.7'
据我了解,内核正在寻找python 3.7
。我的内核列表只有python3
$jupyter kernelspec list
Available kernels:
python3 /usr/local/etc/jupyter/kernels/python3
我看了this link on github,但这没有帮助。如何使jupyter和内核运行在相同的python版本上?
答案 0 :(得分:4)
检查内核规格:
$jupyter kernelspec list
这将向您显示可用的内核。在这种情况下:
python3 /usr/local/etc/jupyter/kernels/python3
在此目录中打开kernel.json
文件,并在argv
键中指定要内核使用的python路径。
答案 1 :(得分:1)
如果有人从Anaconda内部运行Jupyter Notebook并读到此错误,那么任何人阅读该文章:
我找到了一种解决方法,方法是在命令提示符(不是anaconda提示符)中使用pip安装Jupyter:
$pip install jupyter
然后使用已知方法启动Jupyter
$cd 'DirectoryofyourNotebook'
$jupyter notebook
答案 2 :(得分:1)
更新jupyter笔记本为我解决了该问题。 但是请记住,使用命令行对其进行更新。不是Anaconda Navigator
pip install -U jupyter
答案 3 :(得分:0)
我遇到了同样的问题 - 尝试了以上所有方法都没有成功。
上下文:在那台机器上使用 Windows 几年了。我已经将这台机器用作“需要时随时随地编写代码”的笔记本电脑,并且在安装/升级 python 版本或库或环境时并没有非常小心和一致。
对我的修复 - 不知何故,包含 f2py.exe(Numpy - Pandas 在其上构建)的文件夹不在路径中,而是在以“\”结尾的隐藏文件夹中脚本”。 Python 本身在环境变量中很好。它们位于非常不同的文件夹中 - 而通常它们应该位于文件夹树中的紧密分支中。添加在环境变量中有 f2py.exe 的以“\Scripts”结尾的文件夹的完整路径为我解决了内核问题。
答案 4 :(得分:0)
第 2 步命令:-“conda activate(您的 env 文件夹的位置)” 第 3 步命令:-“python -m ipykernel install --user”
作品