通过VSCode的 launch.json文件来启动Pixi环境
我正在尝试构建并运行一个名为 CellProfiler 的图像处理软件。我按照Wiki的指引,使用 Pixi从源码安装,具体是CellProfiler 5。这个方法已经奏效,我可以在命令行通过 pixi run -e dev cp 运行该软件,正如wiki页面底部所建议的那样。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// This command line arguments come from a CellProfiler Wiki
// page called "Getting started using CellProfiler from the
// command line" (https://github.com/CellProfiler/CellProfiler/wiki/Getting-started-using-CellProfiler-from-the-command-line).
// That page assumes that you run CellProfiler using the executable,
// however, this file applies to pixi installations where the
// command line argument is "pixi run -e dev cp" given in
// "Pixi Source Install" (https://github.com/CellProfiler/CellProfiler/wiki/Pixi-Source-Install).
// The arguments meaning is given in the rest of this comment:
// -c -> run CellProfiler in headless mode (no GUI)
// -r -> run the pipeline in batch mode (no GUI)
// -p -> the path to the pipeline file to run
// -o -> the path to the output directory
// -i -> the path to the input directory
"version": "0.2.0",
"configurations": [
{
"name": "CellProfiler (pixi)",
"type": "debugpy",
"request": "launch",
"module": "cellprofiler",
"justMyCode": false,
"console": "integratedTerminal",
"subProcess": false
},
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
//"args": [
// "-c", "-r",
// "-p", ".\\test_pipelines\\Test_Pipeline.cppipe",
// "-o", ".\\test_output\\run_0",
// "-i", ".\\test_input\\1_live_cell"
// ]
}
]
}
The commented out arguments are to run CellProfiler from the command line without a GUI interface. This is a goal for later, for now just getting it to run in debug will do.
当我尝试用这个配置运行调试会话时,命令行尝试执行以下命令;
c: && cd c:\Users\*****\source\repos\CellProfiler && cmd /C "c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe c:\Users\*****\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\launcher 59060 -- C:\Users\*****\source\repos\CellProfiler\src\frontend\cellprofiler\__main__.py "。从命令行没有任何输出,在VSCode的 Output控制台中的结果如下:
2026-06-23 12:33:09.465 [info] resolveDebugConfigurationWithSubstitutedVariables: resolving interpreter for program='C:\Users\*****\source\repos\CellProfiler\src\frontend\cellprofiler\__main__.py'
2026-06-23 12:33:09.466 [info] legacyGetInterpreterDetails: executable='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe' resource='c:\Users\*****\source\repos\CellProfiler\src\frontend\cellprofiler\__main__.py'
2026-06-23 12:33:09.466 [info] resolveDebugConfigurationWithSubstitutedVariables: setting debugConfiguration.python='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe'
2026-06-23 12:33:09.466 [info] Resolving launch configuration with substituted variables
2026-06-23 12:33:09.471 [info] createDebugAdapterDescriptor: request='launch' name='Python Debugger: Current File with Arguments'
2026-06-23 12:33:09.472 [info] legacyGetInterpreterDetails: executable='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe' resource='c:\Users\*****\source\repos\CellProfiler'
2026-06-23 12:33:09.472 [info] legacyResolveEnvironment: Resolving environment 'c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe'
2026-06-23 12:33:09.472 [info] legacyResolveEnvironment: Resolved executable='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe'
2026-06-23 12:33:09.473 [info] resolveEnvironment: legacy resolved executable='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe' version='3.9.23'
2026-06-23 12:33:09.473 [info] getExecutableCommand: executable='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe' version='3.9.23'
2026-06-23 12:33:09.473 [info] createDebugAdapterDescriptor: python command parts='c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe'
2026-06-23 12:33:09.473 [info] DAP Server launched with command: c:\Users\*****\source\repos\CellProfiler\.pixi\envs\dev\python.exe c:\Users\*****\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\adapter
2026-06-23 12:33:10.491 [info] Received 'debugpySockets' event from debugpy.
2026-06-23 12:33:10.494 [info] Received 'debugpySockets' event from debugpy.
2026-06-23 12:33:10.495 [info] Received 'debugpySockets' event from debugpy.
2026-06-23 12:33:13.417 [info] Received 'debugpySockets' event from debugpy.
2026-06-23 12:33:19.601 [info] Received 'debugpySockets' event from debugpy.
2026-06-23 12:33:19.612 [info] Received 'debugpySockets' event from debugpy.
很明显,针对调试从launch.json生成的命令与pixi命令 pixi run -e dev cp 不等价,因此调试器并未在pixi环境中运行。问题在于我不知道如何让pixi与 VSCode调试器协同工作,以生成这个命令或等效的命令。
解决方案
问题通过安装Pixi Code扩展并简化launch.json得以解决。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// This command line arguments come from a CellProfiler Wiki
// page called "Getting started using CellProfiler from the
// command line" (https://github.com/CellProfiler/CellProfiler/wiki/Getting-started-using-CellProfiler-from-the-command-line).
// That page assumes that you run CellProfiler using the executable,
// however, this file applies to pixi installations where the
// command line argument is "pixi run -e dev cp" given in
// "Pixi Source Install" (https://github.com/CellProfiler/CellProfiler/wiki/Pixi-Source-Install).
// The arguments meaning is given in the rest of this comment:
// -c -> run CellProfiler in headless mode (no GUI)
// -r -> run the pipeline in batch mode (no GUI)
// -p -> the path to the pipeline file to run
// -o -> the path to the output directory
// -i -> the path to the input directory
"version": "0.2.0",
"configurations": [
{
"name": "Run CellProfiler module",
"type": "debugpy",
"request": "launch",
"module": "cellprofiler",
"justMyCode": false,
"console": "integratedTerminal"
}
]
}