You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -322,13 +319,15 @@ The implementation uses VSCode's Jupyter server provider API to properly integra
322
319
323
320
### Kernel Spec Resolution
324
321
325
-
The implementation uses a hybrid approach:
322
+
The implementation uses server-native kernel specs with venv isolation:
326
323
327
-
1.**Registers per-venv kernel specs**: The installer registers kernel specs using `ipykernel install --user --name deepnote-venv-<hash>` that point to each venv's Python interpreter
328
-
2.**Queries server for available specs**: Connects to the running Deepnote server using `JupyterLabHelper` and queries available kernel specs via `getKernelSpecs()`
329
-
3.**Prefers venv kernel specs**: Looks for the registered venv kernel spec (`deepnote-venv-<hash>`) first
330
-
4.**Falls back gracefully**: Falls back to other Python kernel specs (like `python3-venv`) if the venv kernel spec is not found
331
-
5.**Uses server-compatible specs**: This ensures compatibility with the Deepnote server's kernel configuration while maintaining venv isolation
324
+
1.**Queries server for available specs**: Connects to the running Deepnote server using `JupyterLabHelper` and queries available kernel specs via `getKernelSpecs()`
325
+
2.**Selects any Python kernel spec**: Selects any available Python kernel spec (e.g., `python3-venv`, `python3`, or the first available kernel)
326
+
3.**Venv isolation via server environment**: The Deepnote server is started with the venv's Python interpreter and environment variables configured:
327
+
-`PATH` is prepended with the venv's `bin/` directory
328
+
-`VIRTUAL_ENV` points to the venv path
329
+
-`PYTHONHOME` is removed to avoid conflicts
330
+
4.**Result**: The kernel uses the venv's Python environment even though it's using a server-native kernel spec, ensuring packages installed via `pip` are available
332
331
333
332
### Virtual Environment Path Handling
334
333
@@ -408,25 +407,20 @@ These changes ensure that Deepnote notebooks can execute cells reliably by:
408
407
2. But the kernel was using a different Python interpreter (system Python or different environment)
409
408
3. So `pip install` went to one environment, but imports came from another
410
409
411
-
**Root Cause**: The kernel was using the venv's Python (correct), but shell commands (`!pip install`) were using the system Python or pyenv (wrong) because they inherit the shell's PATH environment variable.
**Root Cause**: Both the kernel and shell commands (`!pip install`) need to use the venv's Python interpreter, but by default they would use whatever Python is in the system PATH.
416
411
417
-
- Install `ipykernel` in the venv along with deepnote-toolkit
418
-
- Use `python -m ipykernel install --user --name deepnote-venv-<hash>` to register a kernel spec that points to the venv's Python interpreter
419
-
- In the kernel selection logic, prefer the venv kernel spec (`deepnote-venv-<hash>`) when querying the server for available specs
420
-
421
-
2.**Environment variable configuration** (ensures shell commands use venv Python):
412
+
**Solution**: Configure the Deepnote server's environment to use the venv:
422
413
423
414
- When starting the Jupyter server, set environment variables:
424
415
- Prepend venv's `bin/` directory to `PATH`
425
416
- Set `VIRTUAL_ENV` to point to the venv
426
417
- Remove `PYTHONHOME` (can interfere with venv)
427
-
- This ensures `!pip install` and other shell commands use the venv's Python
418
+
- Install `ipykernel` in the venv along with deepnote-toolkit
419
+
- Use any server-native Python kernel spec (e.g., `python3-venv`)
420
+
- The kernel inherits the server's environment, so it uses the venv's Python
421
+
- Shell commands (`!pip install`) also inherit the server's environment, so they use the venv's Python
428
422
429
-
**Result**: Both the kernel and shell commands now use the same Python environment (the venv), so packages installed via `!pip install` or `%pip install` are immediately available for import.
423
+
**Result**: Both the kernel and shell commands use the same Python environment (the venv), so packages installed via `!pip install` or `%pip install` are immediately available for import.
430
424
431
425
### Issue 6: "Venv created with outdated pip version"
0 commit comments