gpt4 book ai didi

python - 我可以打开 jupyter 笔记本,但无法在 Mac 上运行包含 python 脚本的笔记本

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:06 25 4
gpt4 key购买 nike

我已经使用 jupyter 以及 Atom 和 python 一年多了。我目前在 macOS 10.14 上使用 Python 3.7.2。从终端运行 Python 没有问题,这是我运行 sys.path 后得到的 PATH:

['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

我可以在 jupyter 中打开 jupyter 笔记本,但由于某些不明原因,我无法运行该笔记本,并且页面右上角出现红色内核错误,并在我运行时显示以下错误消息点击它:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 73, in post
type=mtype))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 160, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_client/manager.py", line 259, in start_kernel
**kw)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_client/launcher.py", line 138, in launch_kernel
proc = Popen(cmd, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7'

这是我的路径(在命令后获得:nano ~/.bash_profile)

# Homebrew
export PATH=/usr/local/bin:$PATH

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

我已经卸载了计算机上的所有 python 安装,包括 anaconda 版本(python 2.7 除外,因为我的 mac 不接受我删除它)

最佳答案

好吧,我所做的是卸载了 python 并使用 Homebrew 重新安装了所有内容,并且它起作用了

关于python - 我可以打开 jupyter 笔记本,但无法在 Mac 上运行包含 python 脚本的笔记本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55191226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com