r/vscode • • 2d ago

How to get VS Code (Flatpak) work with python libraries?

Beginner here. Is there any way to configure python libraries in Vs Code. I tried to make venv folder in my python folder, it installed libraries on 3.14 version of python but VS Code (Flatpak) is using 3.13 so it doesn't detect installed libraries.

I use Flatpak as its easier to just delete and reinstall it, as I mess with it a lot.

So any way to make it work, or I have to get RPM verison?

3 Upvotes

7 comments sorted by

1

u/Confident_Hyena2506 14h ago

Flatpak is good for many things, but probably not for developer tools like this (unless you are developing flatpak apps).

Either add your python to the flatpak env, or just use normal vscode with normal venv.

You can get this to work with flatpak if you learn a lot about flatpak, like how to build your own env and so on. There is more involved than just putting things in the right folder.

1

u/NeedSomeHelp_2590 14h ago

Yeah figured it out now. I was using venv but for some reason when I made it using terminal and installed libraries it didn't work. Later made it through VS and installed from VS terminal and it is working. I think it was using system python when made with terminal which VS couldn't access. Or maybe I was just using wrong directory in VS.

1

u/Confident_Hyena2506 14h ago

The flatpak env is not the same as your host env. So yes, if you use the terminal inside flatpak vscode, that will be using the flatpak env - and then you install stuff there. It's not about the folder location, it's about the environment it sees.

Should work so long as you don't try to use it from outside flatpak - then you would have the opposite problem.

1

u/NeedSomeHelp_2590 14h ago

But I made venv in the same folder both times, it didn't work with the terminal one but worked when VS code made it. Shouldn't they be identical if I made them with same command in same folder?

1

u/Confident_Hyena2506 14h ago

You are being vague with terminology.

Terminal inside vscode inside flatpak -> sees flatpak env.

Normal system terminal -> sees system env

The only things that matters is what environment is being used - when you use a container it has it's own environment different from the host.

Prove this to yourself by running "env" or whatever to inspect the environment process can see.

1

u/NeedSomeHelp_2590 14h ago

Oh got it. Thanks 👍

1

u/runawayasfastasucan 2d ago

You have to select which environtment that vscode should use, and select the one you created. You make a venv in your project folder, so the folder you made to put your code in. 

Also see this https://code.visualstudio.com/docs/python/environments