Skip to content

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

Closed

Description

@Zaubeerer

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

Activity

  1. burdiyan commented on Dec 2, 2023

    @burdiyan

    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.

  2. baszalmstra commented on Feb 26, 2024

    @baszalmstra
    Contributor

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

    Lets see what happens!

  3. j-bac commented on Apr 2, 2024

    @j-bac

    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. 
    
  4. ruben-arts commented on Apr 2, 2024

    @ruben-arts
    Contributor

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

  5. j-bac commented on Apr 2, 2024

    @j-bac

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

    [pypi-dependencies]
    ipykernel = ">=6.29.3,<6.30"
    
  6. abkfenris commented on Apr 2, 2024

    @abkfenris
    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>"
  7. j-bac commented on Apr 2, 2024

    @j-bac

    Thanks that worked!

  8. b4rlw commented on May 13, 2024

    @b4rlw

    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 😁

  9. roaldarbol commented on Jul 2, 2024

    @roaldarbol
    Contributor

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

  10. ruben-arts commented on Jul 9, 2024

    @ruben-arts
    Contributor
  11. visr commented on Jul 9, 2024

    @visr

    Question, the release notes also mention adding support for https://github.com/microsoft/python-environment-tools. This does not support Pixi: microsoft/python-environment-tools#46. What is the difference between this and the locator? From an outsider perspective they seem to do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions