无法使用Jupyter在Visual Studio Code中运行Python代码-“无法从'Python 3.6.8 64位启动Jupyter内核”

use*_*007 5 python visual-studio-code jupyter-notebook

我已经在最新的Visual Studio中安装了Jupyter扩展:Visual Studio 1.3.01 64 Jupyter 1.1.4

当我使用tensorflow时,我需要Python 3 64bit。

当我尝试运行简单的代码时,我得到:

Jupyter kernel cannot be started from 'Python 3.6.8 64-bit ('tensorflow64': virtualenv)'. Using closest match Python 3.7.0 32-bit instead.
Run Code Online (Sandbox Code Playgroud)

码:

#%%
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)))
Run Code Online (Sandbox Code Playgroud)

如果我不使用VS Code中的Jupyter运行代码,则一切正常。

use*_*007 8

Jupyter发出的消息不是对该问题的最好描述,缺少ipykernel软件包。

解决的方法是使用Python 3.64位将其他python软件包“ ipykernel”安装到虚拟环境中。

pip install ipykernel
Run Code Online (Sandbox Code Playgroud)

附加信息:https : //github.com/Microsoft/vscode-python/issues/3579