Skip to content

Commit c0f19d6

Browse files
Artmannclaude
andcommitted
fix: Install kernel spec into venv instead of user directory
Previously, ipykernel specs were installed with --user flag, placing them in ~/Library/Jupyter/kernels/. This caused the Deepnote Jupyter server to fall back to generic Python kernels because it couldn't discover the venv-specific kernel spec. This resulted in a mismatch where: - Shell commands (!pip install) used the venv's Python (via PATH) - But the kernel interpreter used system Python - Leading to ModuleNotFoundError for packages installed in the venv Now installing kernel specs with --prefix into the venv itself at <venv>/share/jupyter/kernels/. Jupyter automatically discovers kernel specs in this location when started with the venv's Python, ensuring the correct interpreter is used. Each .deepnote file maintains its own isolated venv with its own kernel spec, preventing conflicts when multiple notebooks are open. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b2649a7 commit c0f19d6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/kernels/deepnote/deepnoteToolkitInstaller.node.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller {
6565
const venvPath = this.getVenvPath(deepnoteFileUri);
6666
const venvKey = venvPath.fsPath;
6767

68+
logger.info(`Virtual environment at ${venvKey}.`);
69+
6870
// Wait for any pending installation for this venv to complete
6971
const pendingInstall = this.pendingInstallations.get(venvKey);
7072
if (pendingInstall) {
@@ -210,6 +212,7 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller {
210212
logger.info('deepnote-toolkit installed successfully in venv');
211213

212214
// Install kernel spec so the kernel uses this venv's Python
215+
// Install into the venv itself (not --user) so the Deepnote server can discover it
213216
logger.info('Installing kernel spec for venv...');
214217
try {
215218
// Reuse the process service with system environment
@@ -219,15 +222,20 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller {
219222
'-m',
220223
'ipykernel',
221224
'install',
222-
'--user',
225+
'--prefix',
226+
venvPath.fsPath,
223227
'--name',
224228
`deepnote-venv-${this.getVenvHash(deepnoteFileUri)}`,
225229
'--display-name',
226230
`Deepnote (${this.getDisplayName(deepnoteFileUri)})`
227231
],
228232
{ throwOnStdErr: false }
229233
);
230-
logger.info('Kernel spec installed successfully');
234+
logger.info(
235+
`Kernel spec installed successfully to ${
236+
venvPath.fsPath
237+
}/share/jupyter/kernels/deepnote-venv-${this.getVenvHash(deepnoteFileUri)}`
238+
);
231239
} catch (ex) {
232240
logger.warn(`Failed to install kernel spec: ${ex}`);
233241
// Don't fail the entire installation if kernel spec creation fails

0 commit comments

Comments
 (0)