can not load system-site-packages when using a venv ipykernel
See original GitHub issueEnvironment data
- VS Code version: 1.67.1
- Jupyter Extension version (available under the Extensions sidebar): v2022.4.1011282140
- Python Extension version (available under the Extensions sidebar): v2022.6.1
- OS (Windows | Mac | Linux distro) and version: Windows 19044.1645
- Python and/or Anaconda version: 3.8.10
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Jupyter server running: Local
Expected behaviour
fail to import a module installed in %userprofile% in *.ipynb files but it works in *.py files.
I have set ‘include-system-site-packages = true’ in pyvenv.cfg.
Actual behaviour
failed with ModuleNotFoundError
Steps to reproduce:
- create a virtual enviroment. then install ipykernel.
- import a module installed in %userprofile% in *.ipynb files.
- run a cell.
Logs
Output for Jupyter
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Jupyter
)
XXX
Issue Analytics
- State:
- Created a year ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Running Jupyter notebook in a virtualenv: installed sklearn ...
To install jupyter, (and in a first instance pip, that does not get installed neither in your virtual environment with this command) but ......
Read more >Creating Python Virtual Environment and how to add it to ...
We will not install virtualenv on Linux because we will use venv function to create virtual environment. Install ipykernel.
Read more >Use Virtual Environments Inside Jupyter Notebooks & Jupter ...
We'll do this by creating an isolated python virtual environment for each notebook, so that each notebooks runs inside it's own environment. If...
Read more >venv — Creation of virtual environments — Python 3.11.1 ...
Creating virtual environments¶ ... Running this command creates the target directory (creating any parent directories that don't exist already) and places a ...
Read more >Python Virtual Environments - Office of Research Computing
A Python Virtual environment built on Argo (for example) will not work on Hopper. On Argo, we recommend that you use virtualenv as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for not explaining that, yes thats correct. We found that it completely messes up things. And decided not to add it. This is the first time we’ve had a user complain about this, seems legitimate though. I guess we could add this back if its a non-conda and virtual environment. Then again there are a number of different virtual environments, are poetry considered virtual? We need to be careful in adding them, else we could end up adding them even for environments that would never get them regardless.
I’d suggest just adding this back only for virtual environments (venv, virtualenv, virtualenvwrapper, etc). We used to have startup code that did this, which was later removed.
Thanks for the bug.
Can you print out the sys.path in a notebook and the sys.path in a python terminal and show the difference here?
We should be picking up the pyvenv.cfg settings so I’d like to see what the difference is.