Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHONNOUSERSITE setting isn't being honored. #9995

Closed
derekschinke opened this issue May 12, 2022 · 6 comments · Fixed by #10124
Closed

PYTHONNOUSERSITE setting isn't being honored. #9995

derekschinke opened this issue May 12, 2022 · 6 comments · Fixed by #10124
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) verified Verification succeeded
Milestone

Comments

@derekschinke
Copy link

derekschinke commented May 12, 2022

Environment data

  • VS Code version: 1.67.1
  • Jupyter Extension version (available under the Extensions sidebar): 2022.4.1011282140
  • Python Extension version (available under the Extensions sidebar): 2022.6.1
  • OS (Windows | Mac | Linux distro) and version: macOS 12.3.1
  • Python and/or Anaconda version: Python 3.10.4, conda 4.12.0 (installed through miniforge)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Jupyter server running: Local

Expected behaviour

In Jupyter Notebook cell, run %pip install <package-name> --user, then import <package-name>. Package should download, install, and import.

This runs correctly when starting Jupyter from macOS's Terminal.app, but not in VSCode.

Actual behaviour

import <package-name> fails with ModuleNotFoundError: No module named '<package-name>'. Tested on 3 Macs, both x86 and arm64

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

In a conda environment without pandas installed.

  1. Create a .ipynb file.
  2. Create a python cell that contains %pip install pandas --user
  3. Create a python cell that contains import pandas
  4. Run the notebook

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

Visual Studio Code (1.67.1, undefined, desktop) Jupyter Extension Version: 2022.4.1011282140. Python Extension Version: 2022.6.1. No workspace folder opened. error 20:42:54.854: Exception while attempting zmq : [Error: No native build was found for platform=darwin arch=arm64 runtime=electron abi=101 uv=1 armv=8 libc=glibc node=16.13.0 electron=17.4.1 loaded from: /Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/node_modules/zeromq

at Function.load.path (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/node_modules/node-gyp-build/index.js:1:3163)
at load (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/node_modules/node-gyp-build/index.js:1:648)
at Object.<anonymous> (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/node_modules/zeromq/lib/native.js:1:198)
at Module.u._compile (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:1313)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1216:10)
at Module.load (node:internal/modules/cjs/loader:1035:32)
at Module._load (node:internal/modules/cjs/loader:876:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.s._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:32307)
at Function.b._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:28750)
at Function._._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:97:61719)
at Module.require (node:internal/modules/cjs/loader:1059:19)
at h (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:699)
at Object.<anonymous> (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/node_modules/zeromq/lib/index.js:1:144)
at Module.u._compile (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:1313)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1216:10)
at Module.load (node:internal/modules/cjs/loader:1035:32)
at Module._load (node:internal/modules/cjs/loader:876:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.s._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:32307)
at Function.b._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:28750)
at Function._._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:97:61719)
at Module.require (node:internal/modules/cjs/loader:1059:19)
at h (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:699)
at Object.92747 (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:4028080)
at __webpack_require__ (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:4801729)
at u.zmqSupported (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:539428)
at u.isSupportedForLocalLaunch (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:539171)
at u.get isSupported [as isSupported] (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:539081)
at t.registerTypes (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:551117)
at /Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:4806637
at /Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:4807386
at /Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:4807394
at e.activate (/Users/derekschinke/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/out/extension.node.js:2:4807516)
at Function._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:17454)
at Function._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:17119)
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:14937
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async _activate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:8180)
at async _waitForDepsThenActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:8122)
at async _initialize (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:7486)]

User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 20:42:55.82: Attempting to start a server because of preload conditions ...
info 20:42:55.83: Checking for server existence.
info 20:42:55.83: Checking for server usability.
info 20:42:55.131: Starting Notebook id = .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher for /Users/derekschinke/Developer/magic-install-issue.ipynb (disableUI=true)
info 20:42:55.153: Experiment status for python is {"enabled":true,"optInto":[],"optOutFrom":[]}
info 20:42:55.246: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m pip list

/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m pip list
info 20:42:55.253: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -c "import jupyter"
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -c "import jupyter"
info 20:42:55.253: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -c "import notebook"
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -c "import notebook"
info 20:42:55.273: Preferred Remote kernel for /Users/derekschinke/Developer/magic-install-issue.ipynb is undefined
info 20:42:55.273: Find preferred kernel for /Users/derekschinke/Developer/magic-install-issue.ipynb with metadata {"interpreter":{"hash":"03f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123"},"kernelspec":{"display_name":"Python 3.10.4 ('magic-install-issue')","language":"python","name":"python3"},"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.10.4"},"orig_nbformat":4} & preferred interpreter /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python
info 20:42:55.273: Preferred Remote kernel for /Users/derekschinke/Developer/magic-install-issue.ipynb is undefined
info 20:42:55.273: Preferred kernel .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher is exact match
info 20:42:55.274: PreferredConnection: .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher found for NotebookDocument: /Users/derekschinke/Developer/magic-install-issue.ipynb
info 20:42:55.274: TargetController found ID: .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher for document /Users/derekschinke/Developer/magic-install-issue.ipynb
info 20:42:55.336: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m jupyter kernelspec --version
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m jupyter kernelspec --version
info 20:42:55.475: Starting notebook server.
info 20:42:55.475: Connecting to server
info 20:42:55.475: Launching server
info 20:42:55.475: Starting Notebook
info 20:42:55.560: Registering dummy command feature
info 20:42:55.569: Registering dummy command feature
info 20:42:55.605: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python -m pip list
/opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python -m pip list
info 20:42:55.739: Generating custom default config at /var/folders/9c/_781_1t91l39c6q90y1863vh0000gn/T/05af4f62-3067-4424-a5f6-ec05a7cee255/jupyter_notebook_config.py
info 20:42:55.740: Starting Jupyter Notebook
Starting Jupyter from /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python with command line --no-browser --notebook-dir="/" --config=/var/folders/9c/_781_1t91l39c6q90y1863vh0000gn/T/05af4f62-3067-4424-a5f6-ec05a7cee255/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
info 20:42:55.762: Creating daemon pool for /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python with env variables count 48
info 20:42:55.768: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v --ppid 13901
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v --ppid 13901
info 20:42:55.769: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v --ppid 13901
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v --ppid 13901
info 20:42:55.770: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v --ppid 13901
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v --ppid 13901
info 20:42:55.875: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) -m jupyter notebook --no-browser --notebook-dir="/" --config=/var/folders/9c/_781_1t91l39c6q90y1863vh0000gn/T/05af4f62-3067-4424-a5f6-ec05a7cee255/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) -m jupyter notebook --no-browser --notebook-dir="/" --config=/var/folders/9c/_781_1t91l39c6q90y1863vh0000gn/T/05af4f62-3067-4424-a5f6-ec05a7cee255/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
info 20:42:55.875: Waiting for Jupyter Notebook
info 20:42:56.418: Preferred Remote kernel for /Users/derekschinke/Developer/magic-install-issue.ipynb is undefined
info 20:42:56.418: Find preferred kernel for /Users/derekschinke/Developer/magic-install-issue.ipynb with metadata {"interpreter":{"hash":"03f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123"},"kernelspec":{"display_name":"Python 3.10.4 ('magic-install-issue')","language":"python","name":"python3"},"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.10.4"},"orig_nbformat":4} & preferred interpreter /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python
info 20:42:56.418: Preferred Remote kernel for /Users/derekschinke/Developer/magic-install-issue.ipynb is undefined
info 20:42:56.418: Preferred kernel .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher is exact match
/opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
info 20:42:56.510: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(

[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
info 20:42:56.834: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.

[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /
info 20:42:56.838: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /

[I 20:42:56.837 NotebookApp] Jupyter Notebook 6.4.11 is running at:
info 20:42:56.838: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /
[I 20:42:56.837 NotebookApp] Jupyter Notebook 6.4.11 is running at:

[I 20:42:56.837 NotebookApp] http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
info 20:42:56.838: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /
[I 20:42:56.837 NotebookApp] Jupyter Notebook 6.4.11 is running at:
[I 20:42:56.837 NotebookApp] http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d

info 20:42:56.839: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py

/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py
[I 20:42:56.837 NotebookApp] or http://127.0.0.1:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
info 20:42:56.840: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /
[I 20:42:56.837 NotebookApp] Jupyter Notebook 6.4.11 is running at:
[I 20:42:56.837 NotebookApp] http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
[I 20:42:56.837 NotebookApp] or http://127.0.0.1:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d

info 20:42:56.842: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py

/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py
[I 20:42:56.837 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
info 20:42:56.848: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /
[I 20:42:56.837 NotebookApp] Jupyter Notebook 6.4.11 is running at:
[I 20:42:56.837 NotebookApp] http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
[I 20:42:56.837 NotebookApp] or http://127.0.0.1:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
[I 20:42:56.837 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

[C 20:42:56.842 NotebookApp]

To access the notebook, open this file in a browser:
    file:///Users/derekschinke/Library/Jupyter/runtime/nbserver-14064-open.html
Or copy and paste one of these URLs:
    http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
 or http://127.0.0.1:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d

info 20:42:56.849: /opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/' instead of '"/"' if you require traitlets >=5.
warn(
[I 20:42:56.833 NotebookApp] The port 8888 is already in use, trying another port.
[I 20:42:56.836 NotebookApp] Serving notebooks from local directory: /
[I 20:42:56.837 NotebookApp] Jupyter Notebook 6.4.11 is running at:
[I 20:42:56.837 NotebookApp] http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
[I 20:42:56.837 NotebookApp] or http://127.0.0.1:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
[I 20:42:56.837 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:42:56.842 NotebookApp]

To access the notebook, open this file in a browser:
    file:///Users/derekschinke/Library/Jupyter/runtime/nbserver-14064-open.html
Or copy and paste one of these URLs:
    http://localhost:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d
 or http://127.0.0.1:8889/?token=154d142870a7d9e2a28dd9a9329763f460ffff9c95d09c0d

info 20:42:57.71: Connecting to process server
info 20:42:57.71: Connecting server kernel http://localhost:8889/
info 20:42:57.71: Creating server with url : http://localhost:8889/
info 20:42:57.74: Connection complete server
info 20:42:57.74: Server started.
info 20:42:57.135: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py

/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py
info 20:42:57.135: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py
/opt/homebrew/Caskroom/miniforge/base/envs/adm/bin/python (daemon) ~/.vscode/extensions/ms-toolsai.jupyter-2022.4.1011282140/pythonFiles/vscode_datascience_helpers/getServerInfo.py
[I 20:42:57.129 NotebookApp] Creating new notebook in /Users/derekschinke/Developer
info 20:42:57.170: installMissingDependencies /opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python, ui.disabled=true for resource /Users/derekschinke/Developer/magic-install-issue.ipynb
info 20:42:57.172: Process Execution: > /opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python -c "import ipykernel"
/opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python -c "import ipykernel"
info 20:42:57.422: Spec argv[0] updated from '/opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python' to '/opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python'
info 20:42:57.431: Adding env Variable PYTHONNOUSERSITE to /opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/bin/python
[I 20:42:57.517 NotebookApp] Kernel started: 6191a7bd-6efb-421b-bfe2-689c439996fc, name: python3104jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123
info 20:42:57.522: Waiting for idle on (kernel): 6191a7bd-6efb-421b-bfe2-689c439996fc -> unknown
[W 20:42:57.525 NotebookApp] delete /Users/derekschinke/Developer/magic-install-issue-jvsc-78591770-5869-4ca5-8971-942b566a232e.ipynb
info 20:42:57.825: Finished waiting for idle on (kernel): 6191a7bd-6efb-421b-bfe2-689c439996fc -> idle
info 20:42:57.825: Started session for kernel .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher
info 20:42:57.825: Finished connecting kernel .jvsc74a57bd003f0a5baf3d4363cb202d2faeab65123f6a7ef82ddccbc644603d875f2b98123./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python./opt/homebrew/Caskroom/miniforge/base/envs/magic-install-issue/python.-m#ipykernel_launcher
info 20:42:57.833: UpdateWorkingDirectoryAndPath in Kernel
info 20:42:57.833: Initialize matplotlib for /Users/derekschinke/Developer/magic-install-issue.ipynb
info 20:42:57.833: Executing silently Code (idle) = import os\nimport sys\n%cd "/Users/derekschinke/Developer"\nif os.getcwd() not in sys.path:\nsys.pat
info 20:42:57.845: Executing silently Code (completed) = import os\nimport sys\n%cd "/Users/derekschinke/Developer"\nif os.getcwd() not in sys.path:\nsys.pat
info 20:42:57.845: Waiting for idle on (kernel): 6191a7bd-6efb-421b-bfe2-689c439996fc -> idle
info 20:42:57.845: Finished waiting for idle on (kernel): 6191a7bd-6efb-421b-bfe2-689c439996fc -> idle
info 20:43:1.456: Execute Cell 0 /Users/derekschinke/Developer/magic-install-issue.ipynb
info 20:43:1.457: Execute Cell 1 /Users/derekschinke/Developer/magic-install-issue.ipynb
info 20:43:7.125: Cell 0 executed with state Success
info 20:43:7.347: Cancel all remaining cells true || Error || undefined
info 20:43:7.347: Cancel pending cells
info 20:43:7.347: Cell 1 executed with state Error

@derekschinke derekschinke added the bug Issue identified by VS Code Team member as probable bug label May 12, 2022
@github-actions github-actions bot added the triage-needed Issue needs to be triaged label May 12, 2022
@IanMatthewHuff
Copy link
Member

@derekschinke Is it just with --user that you see this issue? The venv that I was using didn't allow a --user install either in jupyter notebook or in vscode. And when not using --user I got the exact same result in both vscode and in jupyter from the command line. In each case it installed, surfaced a warning that I might need to restart the kernel, then was able to use the import.
image

@IanMatthewHuff IanMatthewHuff added info-needed Issue requires more information from poster cell-magics labels May 12, 2022
@derekschinke
Copy link
Author

derekschinke commented May 12, 2022

When I leave out --user, the install command doesn't work at all and returns ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/opt/homebrew/Caskroom/miniforge/base/envs/adm/lib/python3.10/site-packages/isort'

Restarting kernel after the install doesn't fix the issue either.

@greazer greazer removed the triage-needed Issue needs to be triaged label May 12, 2022
@IanMatthewHuff
Copy link
Member

@derekschinke Just noted in your intro that you are using conda (didn't see that the first time). In general conda and pip should not be mixed. Does the %conda magic command work for you if you use that instead?

@derekschinke
Copy link
Author

derekschinke commented May 14, 2022

Nope, same error when running %conda. Running both %pip and %conda worked before, as recently as 2 weeks ago (before 2022.04.100 I'm guessing)

@IanMatthewHuff
Copy link
Member

@derekschinke I believe that this change here would be what altered the behavior here:
#9379
https://github.com/microsoft/vscode-jupyter/pull/9501/files

Seems like this is a bit of a thorny issue with python package management (you don't have to read all these, just making a note more for myself):
https://stackoverflow.com/questions/35835274/how-to-reuse-global-site-packages-in-conda-env
conda/conda#3162
conda/conda#8770
https://peps.python.org/pep-0370/
https://docs.python.org/3/using/cmdline.html#envvar-PYTHONNOUSERSITE

Per our usage of adding PYTHONNOUSERSITE = True in jupyterKernelService we may want to reconsider this. Pulling back to triage and marking as iteration candidate.

@IanMatthewHuff IanMatthewHuff added needs-triage triage-needed Issue needs to be triaged and removed info-needed Issue requires more information from poster needs-triage labels May 16, 2022
@NicoJG
Copy link

NicoJG commented May 16, 2022

For me, the changes @IanMatthewHuff linked, are very annoying.
I am working on a server with a conda environment set up by the admins.
I do not have permissions to install my own conda environment, but I do have the permissions to install packages through pip.
So I use an existing conda environment with a few packages added using pip.

Before one of the last updates, everything worked fine, but now I cannot import the packages which I installed with pip.
This means I have no way to use packages that are not installed in the existing conda environment, and basically Jupyter in VS Code is useless for me at the moment.

@greazer greazer changed the title Magic installs cause imports to return ModuleNotFoundError PYTHONNOUSERSITE setting isn't being honored. May 16, 2022
@greazer greazer added notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) notebook-execution and removed triage-needed Issue needs to be triaged iteration-candidate labels May 16, 2022
@greazer greazer added this to the June 2022 milestone May 16, 2022
@greazer greazer modified the milestones: June 2022, May 2022 May 16, 2022
@rchiodo rchiodo self-assigned this May 24, 2022
@amunger amunger added the verified Verification succeeded label Jun 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants