我有以下设置:
Python 3.7.2
macOS 10.14
原子1.35.1
脚本 3.18.1
氢2.8.0
运行代码可以在Terminal
以及带有script
的atom中运行,但使用氢运行代码时没有任何反应:
在Hydrogen
的Language Mappings
中写道:
{ "python": "magicpython", "python3": "magicpython"}
运行时jupyter kernelspec list
我得到:python3/usr/local/etc/jupyter/kernels/python3
。该目录中有一个 kernel.json
文件,其内容如下:
{
"argv": [
"/usr/local/Cellar/python/3.7.2_2/bin",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"env": {
"PYTHONPATH": "/usr/local/Cellar/ipython/7.3.0/libexec/lib/python3.7/site-packages:/usr/local/Cellar/ipython/7.3.0/libexec/vendor/lib/python3.7/site-packages"
}
,
"display_name": "Python 3",
"language": "python"
}
在目录/usr/local/Cellar/python/3.7.2_2/bin
中有以下项目
2to3 pip3.7 python3.7-config
2to3-3.7 pydoc3 python3.7m
easy_install-3.7 pydoc3.7 python3.7m-config
idle3 python3 pyvenv
idle3.7 python3-config pyvenv-3.7
pip3 python3.7 wheel3
kernel.json 文件中的路径是否正确?
我也看过这个github page但我无法解决问题
我做错了什么?
最佳答案
您的 kernelspec argv 参数指向 ../python.3x/bin
而不是直接指向 python3
可执行文件。直接使用 ../python.3x/bin/python3
指向可执行文件更为典型,并且可能是问题所在。
你是如何安装内核的?我建议看看this kernel installation guide在您的情况下,可能会使用 python3 -m ipykernel install
重新安装内核。我认为这会起作用,但是,手动编辑 kernel.json 文件将是解决此问题的另一种(不推荐)方法。
关于python - atom : hydrogen installed, 但代码未运行(在 macOS 上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55200206/