admin管理员组文章数量:1180551
I'm using NixOS on WSL2 and Visual Studio Code on Windows with the WSL extension. I've created a virtual environment in NixOS, and I want to use the python command of the virtual environment as the Python interpreter in VS Code. However, I'm encountering issues selecting the correct interpreter.
My setup:
NixOS installed on WSL2
Visual Studio Code on Windows with the WSL extension (to access all file in WSL)
Python virtual environment created in NixOS (see flake at the end of the question)
When I run which python inside my virtual environment in NixOS, I get:
/nix/store/24w9ckmkq0asaif83c13z53yraq584lm-python3-3.14.0a4/bin/python
I've tried to select this path as my interpreter in VS Code by adapting it to the Windows WSL path format:
\wsl.localhost\NixOS\nix\store\24w9ckmkq0asaif83c13z53yraq584lm-python3-3.14.0a4\bin\python
However, VS Code only allows me to choose executable (.exe) files. This makes sense, as the Linux executable can't be run directly from Windows. Is it possible to select this NixOS WSL Python interpreter for use in VS Code on Windows? If so, how can I do it? I understand that a Linux executable can't be run directly from Windows, but I'm hoping there's a way to configure VS Code to use the WSL Python interpreter seamlessly. Any guidance on how to properly set this up would be greatly appreciated.
My flake file bring nothing to understand the problem. It is to make the problem reproductible:
{
description = "Python and Manim development environment";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
python314
manim
];
shellHook = ''
echo "Development environment for Python and Manim"
echo "Run 'python' to start Python interpreter"
echo "Run 'manim' to start Manim"
'';
};
}
);
}
本文标签:
版权声明:本文标题:How to select a NixOS WSL Python interpreter(from a virtual environment) in Visual Studio Code on Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738214657a2069245.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论