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

Support automatic recognition of pixi environments in IDEs: VS Code #411

Open
Zaubeerer opened this issue Oct 25, 2023 · 9 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@Zaubeerer
Copy link

Zaubeerer commented Oct 25, 2023

Problem description

As discussed on Discord, there currently isn't a proper integration with VS Code yet.

It would be great if pixi environments automagically show up when selecting the Python interpreter via Python: Select Interpreter (see VS Code Python Interpreter Docs), as do conda, poetry, venv and other environments.

Current workaround

Manually select the pixi environment python executable as described in the VS Code Docs and mentiond in #166 (comment).

However, this may not work for all VS Code Python features as described in #412.

Related information

@burdiyan
Copy link

burdiyan commented Dec 2, 2023

I would really love that! But I really hope that it could be made without any ties to Python. I really like that Pixi positions itself as being cross-platform and ecosystem-agnostic. So many people don't see Conda as a general-purpose package manager, because they think it's Python-only. And I see where it comes from, but I hope it won't be the case for Pixi.

E.g. direnv has nice VS Code extensions that would load the environment into the IDE on startup. Probably something like that could be done for Pixi.

@baszalmstra
Copy link
Contributor

I started some initial work here: microsoft/vscode-python#22968

Lets see what happens!

@j-bac
Copy link

j-bac commented Apr 2, 2024

It seems there is a problem for jupyter notebooks inside vscode. It is possible to manually specify a pixi python interpreter as kernel but vscode does not detect ipykernel even if it is installed:

Running cells with 'envs/.pixi/envs/default/bin/python' requires the ipykernel package.
Run the following command to install 'ipykernel' into the Python environment. 

@ruben-arts
Copy link
Contributor

@j-bac is ipykernel in the same environments as the python interpeter you specify here?

@j-bac
Copy link

j-bac commented Apr 2, 2024

Yes it is part of the pixi.toml (which defines a single environment)

[pypi-dependencies]
ipykernel = ">=6.29.3,<6.30"

@abkfenris
Copy link
Contributor

I was able to get the IPython kernel to work in VS Code by running the kernelspec install inside the pixi environment.

[tasks]
install-kernel = "python -m ipykernel install --user --name <kernel name> --display-name <kernel name>"

@j-bac
Copy link

j-bac commented Apr 2, 2024

Thanks that worked!

@b4rlw
Copy link

b4rlw commented May 13, 2024

A side effect of no auto-discovery is that if you initialise a new project and create a Jupyter notebook - VSCode won't show you any Pixi kernels before you firstly, create any .py file and manually select your Pixi env's Python interpreter. After a restart of the Jupyter notebook, you will be able to use that Pixi Python interpreter as a kernel without having to run any kernel creation commands manually. I assume most VSCode users will be used to this pattern by now, but thought I'd mention it incase anyone is doing that dance for the first time 😁

@roaldarbol
Copy link

I guess this issue can be closed, right? Amazing work @baszalmstra! 🥳

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

No branches or pull requests

8 participants