Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run Python code in Visual Studio Code with Jupyter - "Jupyter kernel cannot be started from 'Python 3.6.8 64-bit"

I've installed Jupyter extension in the latest Visual Studio: Visual Studio 1.3.01 64 Jupyter 1.1.4

As I am using tensorflow I need Python 3 64bit.

When I try to run simple code I get:

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

Code:

#%%
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)))

All works fine if I Run code not using Jupyter from VS Code.

like image 975
user007 Avatar asked Jan 01 '19 14:01

user007


2 Answers

Message from Jupyter is not the best description of the issue, missing ipykernel package.

Fix was to install additional python package 'ipykernel' into virtual environment with Python 3.64 bit.

pip install ipykernel

Additional info: https://github.com/Microsoft/vscode-python/issues/3579

like image 109
user007 Avatar answered Oct 18 '22 09:10

user007


conda create --name test_env
conda activate test_env
conda install -c anaconda ipykernel
python -m ipykernel install --user --name=test_env

Or this You can run this it might work

ipython kernel install --user --name=ENVNAME
like image 40
Manoj Kumar Singh Avatar answered Oct 18 '22 07:10

Manoj Kumar Singh