question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

On a remote server, kernel picker doesn't show virtual environments

See original GitHub issue

Issue Type: Bug

I use the Remote - SSH and Python extensions to run Python code on a remote server. I created a virtual environment test_venvon the remote server I connect to, which contains pandas and jupyter. I’m able to select this environment in VS Code:

image

I can run a simple Python script from VS Code using this interpreter:

import pandas as pd
filename = 'test.csv'
df = pd.read_csv(filename)
print(df)

This runs fine. However, if I try to run a Jupyter notebook which does the same things:

{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": 3
  },
  "orig_nbformat": 2
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "import pandas as pd"
   ],
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "filename = 'test.csv'\n",
    "df = pd.read_csv(filename)\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}

VS Code complains that ipykernel is not installed, and it doesn’t run the notebook:

image

This means that VS Code uses the selected environment when running a Python script, but not when running a notebook, as also confirmed by the fact that it’s trying to use Python 2.7 (the virtual environment has Python 3.8) . This is a major bug: basically you cannot run Jupyter notebooks with VS Code on remote servers.

Extension version: 2021.5.842923320 VS Code version: Code 1.56.2 (054a9295330880ed74ceaedda236253b4f39a335, 2021-05-12T17:44:30.902Z) OS version: Darwin x64 19.6.0 Remote OS version: Linux x64 5.4.0-52-generic

System Info
Item Value
CPUs Intel® Core™ i7-7820HQ CPU @ 2.90GHz (8 x 2900)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.87GB free)
Process Argv –crash-reporter-id df4f7917-f728-4290-9500-a3632318c3e7
Screen Reader no
VM 0%
Item Value
Remote SSH: xxxx
OS Linux x64 5.4.0-52-generic
CPUs Intel® Xeon® CPU E5-2698 v4 @ 2.20GHz (80 x 2696)
Memory (System) 503.78GB (343.49GB free)
VM 0%

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
DavidKutucommented, Jun 14, 2021

I have another couple of questions/suggestions @AndreaPi.

  • Could you please update the Jupyter release to the latest version, and check if the issue still happens?
  • The python file and the notebook you’re running, are they on the same folder?
0reactions
AndreaPicommented, Jun 15, 2021

Installing the new Jupyter release (which just recently came out) solved everything! Thank you @DavidKutu . Closing the issue now

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Virtual environments not listed in Kernels until i reload ...
Run notebook, & view kernels Create virtual environment Close notebook, open a notebook, the new venv is not dipslayed in the kernel picker...
Read more >
Cannot find python kernels corresponding to Virtual ...
I've selected "default", letting VSCode starting a server on the local (remote) host, and then the interpeter / kernel was enabled.
Read more >
Using Jupyter Notebook in Virtual Environment - GeeksforGeeks
Click on the kernel and click change kernel you will be able to see the kernel you just created.
Read more >
Working with Jupyter Notebooks in Visual Studio Code
Work with Jupyter code cells; View, inspect, and filter variables using the Variable Explorer and Data Viewer; Connect to a remote Jupyter server;...
Read more >
Python Virtual Environments: A Primer
If the name shows up, then you know that your virtual environment is active, and you can install your external dependencies. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found