-
Notifications
You must be signed in to change notification settings - Fork 293
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
Comments
@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. |
When I leave out Restarting kernel after the install doesn't fix the issue either. |
@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? |
Nope, same error when running |
@derekschinke I believe that this change here would be what altered the behavior here: 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): Per our usage of adding PYTHONNOUSERSITE = True in jupyterKernelService we may want to reconsider this. Pulling back to triage and marking as iteration candidate. |
For me, the changes @IanMatthewHuff linked, are very annoying. Before one of the last updates, everything worked fine, but now I cannot import the packages which I installed with pip. |
ModuleNotFoundError
Environment data
Expected behaviour
In Jupyter Notebook cell, run
%pip install <package-name> --user
, thenimport <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 withModuleNotFoundError: No module named '<package-name>'
. Tested on 3 Macs, both x86 and arm64Steps 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..ipynb
file.%pip install pandas --user
import pandas
Logs
Output for
Jupyter
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toJupyter
)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
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
[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
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
[C 20:42:56.842 NotebookApp]
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]
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
The text was updated successfully, but these errors were encountered: