我在最新的 Visual Studio 中安装了 Jupyter 扩展:Visual Studio 1.3.01 64 Jupyter 1.1.4
因为我使用的是 tensorflow,所以我需要 Python 3 64 位。
当我尝试运行简单代码时,我得到:
Jupyter kernel cannot be started from 'Python 3.6.8 64-bit ('tensorflow64': virtualenv)'. Using closest match Python 3.7.0 32-bit instead.
代码:
#%%
import tensorflow as tf
session = tf.Session()
hello = tf.constant("Hello from Milan.")
print(session.run(hello))
a = tf.constant(20)
b = tf.constant(22)
print('a + b = {0}'.format(session.run(a + b)))
如果我不使用 VS Code 中的 Jupyter 运行代码,一切正常。
原文由 user007 发布,翻译遵循 CC BY-SA 4.0 许可协议
来自 Jupyter 的消息并不是问题的最佳描述,缺少 ipykernel 包。
修复是使用 Python 3.64 位将额外的 python 包“ipykernel”安装到虚拟环境中。
附加信息: https ://github.com/Microsoft/vscode-python/issues/3579