Skip to content
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

Cannot load python interpreter #26

Closed
essembeh opened this issue Dec 1, 2020 · 8 comments
Closed

Cannot load python interpreter #26

essembeh opened this issue Dec 1, 2020 · 8 comments

Comments

@essembeh
Copy link

essembeh commented Dec 1, 2020

Hi

I'm trying the flathub version of Vscodium with the ms-python.python extension and I'm experiencing problem while selecting my python interpreter.

I created the my virtual environment in a .venv directory, but when I tell vscodium to use this venv as python interpreter either using the command palette to select it or by directly setting "python.pythonPath": ".venv/bin/python", I get no error, but it does not seem to work since I get popup messages telling me it cannot find my formatter (which is properly installed in my venv, I checked in command line).

Since I had to tweak the vscodium shell setting to properly use my ZSH shell as documented with:

{
    "terminal.integrated.shell.linux": "/usr/bin/env",
    "terminal.integrated.shellArgs.linux": ["--", "flatpak-spawn", "--host", "zsh"]
}

I'm wondering if there is not a sandbox issue here you could help me to fix?
I tried to use "python.pythonPath": "flatpak-spawn --host .venv/bin/python" as it works in the embedded vscodium shell, but the extension does not like it.

Steps to reproduce:

  • create a project dir
  • create a venv with black in it
python3 -m virtualenv venv
source venv/bin/activate
pip install black
  • open the folder in vscodium
  • use this venv/bin/python as interpreter
  • use ̀black` as python code formater
  • format a python file and you'll get the error

Thanks for any help on this ;)

@noonsleeper
Copy link
Collaborator

hey @essembeh, I have the same situation with ShellCheck extension and my hack was use a little script to call the flatpak-spawn and the parameters.

"python.pythonPath": "flatpak-spawn --host .venv/bin/python"

Here Codium and Code detect the command + white spaces + parameters as one large command name but not as a separate thing like shell does.

My little hack for shellcheck to roundabout is this:

"shellcheck.executablePath": "/home/nslpr/bin/shellcheck-spawn",

shellcheck-spawn:

#!/usr/bin/env sh
/usr/bin/env -- flatpak-spawn --host shellcheck "$@"

Don't forget to give exec permission to the script

chmod u+x /home/nslpr/bin/shellcheck-spawn

I think maybe could you try to start with something like this

"python.pythonPath": "/home/nslpr/bin/python-spawn"

python-spawn:

#!/usr/bin/env sh
/usr/bin/env -- flatpak-spawn --host .venv/bin/python "$@"

but to me, the relative path for the binary .venv/bin/ could cause a misbehaviour and maybe you need to hack a little more over this to get a nice result. If you found a solution to this I will happy to add this on the FAQ.

Cheers, and thanks for report this. =)

@essembeh
Copy link
Author

essembeh commented Dec 5, 2020

Hi @noonsleeper

Clever workaround, I'll use it.
To me, using the relative path to detect a venv is not a bloking feature, as the CWD is the project folder while run by vscodium.

I suspected that the Python extension was maybe missing something to use the flatpak-spawn command, you confirmed this as the command cannot contain spaces, maybe I should open the ticket in the extension project for them to provide a way to run command with spaces?

Thanks again.

@noonsleeper
Copy link
Collaborator

I suspected that the Python extension was maybe missing something to use the flatpak-spawn command, you confirmed this as the command cannot contain spaces, maybe I should open the ticket in the extension project for them to provide a way to run command with spaces?

I think is a vscode's problem, the interpretation of any string with white spaces in double quote run in the same problem. But I'm not 100% sure.

@noonsleeper
Copy link
Collaborator

hey @essembeh due to the microsoft/vscode-python#14901 desition I'll close this issue =(. If you still having problems with, please don't hesitate to open a new ticket. =)

@essembeh
Copy link
Author

Hey, too bad this issue couldn't be fixed upstream.
This means I won't be able to use vscodium installed with flatpak.

Thanks

@Termuellinator
Copy link

Termuellinator commented Jun 15, 2023

@noonsleeper am i missing something or does that (at least for the python interpreter) only work without flatpak override --user com.vscodium.codium --no-talk-name=org.freedesktop.Flatpak ?

Also, it's not entirely clear to me from the FAQ what that actually does - i would have expected that no spawn at all would be possible without access to the Flatpak bus?

Other than that the workaround seems to work (tested for system python and system black). It's a real shame Microsoft doesn't consider Flatpak relevant enough 🤦‍♂️

@Altonss
Copy link

Altonss commented Oct 19, 2024

I have a similar issue with my Python path: the only thing I see is :
image

No local conda environment is showing up at all. If I want to create a conda environement from within vscodium I get this error : Install `conda` to create conda environments.

The readme isn't very clear about a possible fix for this issue, could anyone explain how they managed to solve this issue?

@noonsleeper
Copy link
Collaborator

@Altonss please create a new ticket.

@flathub flathub locked as resolved and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants