skip to Main Content

I have a venv then a project sub folder . When I try and use ipynb file in the project folder I need to create a python environment.

So I go and find the python.exe from the venv folder and point to it.

Vscode then installs and creates it’s own .venv folder in the subfolder of the project itself.

That .venv does not have any packages in it and ist redundant.

How can I have it use the python.exe file from the global venv folder instead

2

Answers


  1. Delete your two .venv folders rm -rf .venv and instead of activating the venv from your local terminal / iTerm, try starting it from the terminal inside of VSCode using "Create Environment" and see if the redundancy is resolved.

    VSCode Environments

    Login or Signup to reply.
  2. I’m not 100% clear what the issue is, but if I’ve understood correctly – you need to select the global venv from your vscode notebook, and for some reason vscode wants to use a (non-existent) local version.

    Usually you just click on the icon in the top right corner of the notebook, you’ll get presented with a list of environments that vscode has discovered, and you simply select the "global" one.

    However vscode’s notebook discovery only looks in certain places, if the environment you want to use isn’t being displayed in the list of environments there’s a trick – vscode notebooks doesn’t let you enter a path to an environment. But you can set the project venv (the one that normal *.py files use via a path then then you can select it as normal for your notebooks)

    Open "Comamnd Palette" from the menu (Ctrl-Shift-P or F1 for me) and select "Python: Select Interpreter" and then "Enter Interpreter Path" – from there you can set the path for your project, and that environment should now also be available for notebooks if it wasn’t before.

    If none of this is relevant it may help if you edit your question with more details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search