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
{{ message }}
Repository navigation
Jupyter Lab: non-activated venv obscures site-packages path for system Python #1043
open/create Test.ipynb and add import matplotlib.pyplot as plt
observe import error
pyrefly dump-config gives the following:
INFO Checking project configured at `/Users/dannyyang/Documents/Documents/GitHub/scratch/pyrefly.toml`
Configuration at `/Users/dannyyang/Documents/Documents/GitHub/scratch/pyrefly.toml`
Using interpreter: /Users/dannyyang/Documents/Documents/GitHub/scratch/venv/bin/python3
Covered files:
/Users/dannyyang/Documents/Documents/GitHub/scratch/.pytype/imports/default.pyi
/Users/dannyyang/Documents/Documents/GitHub/scratch/.pytype/pyi/pytype.pyi
/Users/dannyyang/Documents/Documents/GitHub/scratch/compare.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/docs2types/extract_and_apply_annotations.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/docs2types/extract_and_apply_defaults.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/docs2types/test_package/__init__.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/docs2types/tests/__init__.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/docs2types/tests/extract_and_apply_defaults_test.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/generate_expected_output.py
/Users/dannyyang/Documents/Documents/GitHub/scratch/mypy/compare_mypy_pyrefly.py
...and 8875 more
Import root (inferred from project layout): "/Users/dannyyang/Documents/Documents/GitHub/scratch"
Site package path queried from interpreter: ["/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12", "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload", "/Users/dannyyang/Documents/Documents/GitHub/scratch/venv/lib/python3.12/site-packages"]
So it's using the interpreter in the venv in the parent directory, and the site package path does not include the system python one (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages)
Is this expected behavior?
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
The dump-config output has /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12 as the first item in the site package path list, but the description claims that the site package path does not include /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12. Any chance you could clarify that part?
This works fine for me as well; Any chance you actually created the notebook from a ipykernel installation that is in the venv ? It may be that the notebook metadata remembers that you used that kernel and somehow managed to pick it up again; so even if not activated before running jupyter-lab, you might pick up a kernel in a different place (typically if you did some python -m ipykernel install
Activity
grievejia commentedon Sep 8, 2025
The
dump-configoutput has/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12as the first item in the site package path list, but the description claims that the site package path does not include/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12. Any chance you could clarify that part?yangdanny97 commentedon Sep 9, 2025
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12 (included)
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (missing)
MarcoGorelli commentedon Feb 25, 2026
Where does the import error happen?
I've followed the steps but this works fine for me
Carreau commentedon Mar 5, 2026
This works fine for me as well; Any chance you actually created the notebook from a ipykernel installation that is in the venv ? It may be that the notebook metadata remembers that you used that kernel and somehow managed to pick it up again; so even if not activated before running jupyter-lab, you might pick up a kernel in a different place (typically if you did some
python -m ipykernel installyangdanny97 commentedon Mar 6, 2026
I'll try to repro this again tomorrow, if it was just a problem on my machine we can close it
yangdanny97 commentedon Mar 13, 2026
Closing due to no repro
Carreau commentedon Mar 16, 2026
Thanks for re-trying.