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

Python environments issue #373

Open
Altonss opened this issue Oct 20, 2024 · 14 comments
Open

Python environments issue #373

Altonss opened this issue Oct 20, 2024 · 14 comments
Assignees

Comments

@Altonss
Copy link

Altonss commented Oct 20, 2024

I have an 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. conda is installed on my system!

Originally posted by @Altonss in #26 (comment)

@noonsleeper noonsleeper self-assigned this Oct 20, 2024
@noonsleeper
Copy link
Collaborator

Hi @Altonss, how conda works? This works similar to pyenv?

I have the default permission for com.vscodium.codium and this on my zshrc and bashrc files

### Load pyenv automatically
PYENV_ROOT="${HOME}/.pyenv"
export PYENV_ROOT
command -v pyenv >/dev/null || export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init -)"

### Load pyenv-virtualenv automatically
eval "$(pyenv virtualenv-init -)"

This allows me to work with my virtualenvs on flatpak's vscodium, is there something like that for conda? Are the conda binaries and environments on your home directory?

@Altonss
Copy link
Author

Altonss commented Oct 20, 2024

I don't know about pyenv, but when creating a conda environment (with conda create -n testenv), it is located here:

environment location: /home/user/.conda/envs/testenv .

This works all fine in the terminal (with my system bash). But VSCodium has a special integration of those environments at several locations, and with conda none seem to work:

  • select interpreter (bottom right), should also show the local conda environements available!
  • If this select interpreter menu, you can also choose to create a new conda environement, but this fails with this message popup Install conda to create conda environments..
  • Python notebook: on the top right you can select the kernel, but again no conda environement is available.

This is maybe more an issue with conda (as Venv seems to work).

@Altonss
Copy link
Author

Altonss commented Oct 20, 2024

This issue on the VSCode flatpak seems similar: flathub/com.visualstudio.code#396

@noonsleeper
Copy link
Collaborator

Well for me looks more it's that vscodium is not able to found where is located the conda binary, maybe because it is system-wide see. Flatpak, even if the permissions say that has access to the host filesystem, it is still on a sandbox that does not allow accessing the common binary path of the system.

Can you run command -v conda? If this is the case, installing conda binary on your home like pyenv does will workaround your problem

@Altonss
Copy link
Author

Altonss commented Oct 21, 2024

command -v conda

This just returns conda.

@Altonss
Copy link
Author

Altonss commented Oct 21, 2024

Installing conda inside of the flatpak by default might actually be a good solution, for an out of the box solution for VSCodium to work well.
Something like this should be easy to implement: flathub/com.jetbrains.PyCharm-Community#326

@daiyam
Copy link
Collaborator

daiyam commented Oct 21, 2024

I disagree to have conda builtin in VSCodium.

You should use a flatpak extension or override --env=VARIABLE_NAME=VARIABLE_VALUE to pass the env variables needed for conda.

@Altonss
Copy link
Author

Altonss commented Oct 21, 2024

I disagree to have conda builtin in VSCodium.

You should use a flatpak extension or override --env=VARIABLE_NAME=VARIABLE_VALUE to pass the env variables needed for conda.

What would be the reason for not wanting a builtin conda installation? AFAIK the same is currently done with python executable, being builtin in VSCodium...

@daiyam
Copy link
Collaborator

daiyam commented Oct 21, 2024

VSCodium is a general purpose IDE, so we can't cater it to a specific language.
If we integrate conda then we will have to do the same for dependencies of other languages.

Flatpak is sandboxed so you need to provide to the app the necessary access to your system conda (with extensions or env overrides).

@noonsleeper
Copy link
Collaborator

AFAIK the same is currently done with python executable, being builtin in VSCodium...

Python is built-in in org.freedesktop.Sdk (the base container used to build com.vscodium.codium) like any other tools like git, I do not integrate directly, also I share the @daiyam's vision here, is a general purpose IDE.

Said that, I think if you create an extension on namespace com.visualstudio.code.tool like https://github.com/flathub/com.visualstudio.code.tool.podman will be more beneficial for all since can be use not only for codium, but code and code-oss, all the logic to load that extensions is already in place on the vscodium manifest

add-extensions:
com.visualstudio.code.tool:
directory: tools
subdirectories: true
version: '24.08'
add-ld-path: lib
no-autodownload: true

@Altonss
Copy link
Author

Altonss commented Oct 21, 2024

Python is built-in in org.freedesktop.Sdk (the base container used to build com.vscodium.codium) like any other tools like git, I do not integrate directly, also I share the @daiyam's vision here, is a general purpose IDE.

I agree, but whatever the technical justification, the fact is that the user experience for a developer is broken by default (at least for very common python projects).

If the only acceptable solution to this, is an extension, how would be the user experience? Is it a simple install from flathub and it works?

How about guiding the user, when he encounters the error message I mentioned,

  • Install conda to create conda environments.

would it be possible to explain/link to the solution or would this require a too complex patch?

@noonsleeper
Copy link
Collaborator

noonsleeper commented Oct 21, 2024

I agree, but whatever the technical justification, the fact is that the user experience for a developer is broken by default (at least for very common python projects).

I think "broken by default" is not the best statement, the isolation of the environment is intended here, not only for this package but with any flatpak package, then if the developers of a tool or any user want the features that flatpak provide they need to fix the tool or do a workaround to be compliant with flatpak sandbox, if you think that is not for you, you can find the regular packages for your distribution here

If the only acceptable solution to this, is an extension, how would be the user experience? Is it a simple install from flathub and it works?

when someone add something like this,

add-extensions:
com.visualstudio.code.tool:
directory: tools
subdirectories: true
version: '24.08'
add-ld-path: lib
no-autodownload: true

then if you download the tool like

flatpak install flathub com.visualstudio.code.tool.podman

After restart codium this tool is available inside the codium's sandbox without any other user intervention.

How about guiding the user, when he encounters the error message I mentioned,

  • Install conda to create conda environments.

would it be possible to explain/link to the solution or would this require a too complex patch?

This kind of guiding are already in the FAQ, then will be needed to add a solution to this particular in the same way on README.md as well

@Altonss
Copy link
Author

Altonss commented Oct 21, 2024

I think "broken by default" is not the best statement, the isolation of the environment is intended here, not only for this package but with any flatpak package, then if the developers of a tool or any user want the features that flatpak provide they need to fix the tool or do a workaround to be compliant with flatpak sandbox,

Sure, but the underlying (VSCodium) tool isn't really well adapted for this isolation and fails in strange ways (like this very issue shows), which is totally understandable and normal :) So yes the experience is kind of "broken" in the sense that in order to have a working environment, one has to do all the research and fixing we are for example doing in this issue ^^.
But that's okay, since that's what I'm/we are trying to improve here ;)

@noonsleeper
Copy link
Collaborator

Like a mention before, I think the best solution for your needs is to install the distribution package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants