Skip to content

Pixi errror when loading pytest in VS code #23773

Closed

Description

Type: Bug

Behaviour

I get a pytest discovery error when starting pytest from the vs code testing window. The systems utilizes micromamba as the python package manager, with an alias set up between conda -> micromamba. The error originates from pixi not being found,

Steps to reproduce:

  1. Use micromamba environment that is activated in powershell
  2. Open VSCode and the testing toolbar (with the Python Extension set to 2024.10.0)
  3. Tests will not be discovered

Diagnostic data

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

XXX

Extension version: 2024.10.0
VS Code version: Code 1.91.0 (ea1445cc7016315d0f5728f8e8b12a45dc0a7286, 2024-07-01T18:52:22.949Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Micromamba
  • Value of the python.languageServer setting: Default
User Settings


condaPath: "<placeholder>"

languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
autoDocstring - Python Docstring Generator njpwerner.autodocstring 0.6.1
CodeSnap adpyke.codesnap 1.3.4
CSV to Table phplasma.csv-to-table 1.4.0
Data Wrangler ms-toolsai.datawrangler 1.4.1
FindItFaster TomRijndorp.find-it-faster 0.0.38
Git Graph mhutchie.git-graph 1.30.0
GitLens — Git supercharged eamodio.gitlens 15.1.0
Hex Editor ms-vscode.hexeditor 1.10.0
JavaScript Debugger ms-vscode.js-debug 1.91.0
json ZainChen.json 2.0.2
Jupyter ms-toolsai.jupyter 2024.6.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.18
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Live Preview ms-vscode.live-server 0.4.13
Path Intellisense christian-kohler.path-intellisense 2.9.0
Pretty Formatter mblode.pretty-formatter 0.2.4
Pylance ms-python.vscode-pylance 2024.6.1
Python ms-python.python 2024.11.2024070801
Python Debugger ms-python.debugpy 2024.6.0
Rainbow CSV mechatroner.rainbow-csv 3.12.0
SQLite alexcvzz.vscode-sqlite 0.14.1
SVG jock.svg 1.5.4
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
Todo Tree Gruntfuggly.todo-tree 0.0.226
System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 23.71GB (5.42GB free)
Process Argv --folder-uri=vscode-remote://wsl+Ubuntu-22.04/home/adam/Documents/Git/QUIET --remote=wsl+Ubuntu-22.04
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-22.04
OS Linux x64 5.15.153.1-microsoft-standard-WSL2
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 0)
Memory (System) 11.54GB (9.78GB free)
VM 0%

Activity

  1. adam-lagoda commented on Jul 9, 2024

    @adam-lagoda
    Author

    image

  2. rafrafek commented on Jul 9, 2024

    @rafrafek

    I have the same issue that started occurring after the latest VS Code Python extension update. I use Poetry to create my virtual environments, and I don't even know what Pixi is.

    I'm getting a "pytest Discovery Error" and am unable to launch any tests in VS Code.

  3. adam-lagoda commented on Jul 9, 2024

    @adam-lagoda
    Author

    I have tested that downgrading to v2024.8.1 works Rafał (@rafrafek). However this is a temporary solution, and I would highly appreciate fixing the bug by the core team

  4. rafrafek commented on Jul 9, 2024

    @rafrafek

    My logs:

    2024-07-09 14:41:13.122 [info] Experiment 'pythonCreateEnvOnPipInstall' is active
    2024-07-09 14:41:13.122 [info] Experiment 'pythonRecommendTensorboardExt' is active
    2024-07-09 14:41:13.122 [info] Experiment 'pythonTerminalEnvVarActivation' is active
    2024-07-09 14:41:13.122 [info] Experiment 'pythonTestAdapter' is active
    2024-07-09 14:41:13.122 [error] Reading directory to watch failed [Error: ENOENT: no such file or directory, scandir '/Users/username/Projects/project-name/.pixi/envs'
    	at Object.readdirSync (node:fs:1515:3)
    	at t.readdirSync (node:electron/js2c/node_init:2:11289)
    	at /Users/username/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/out/client/extension.js:2:574598
    	at /Users/username/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/out/client/extension.js:2:574789
    	at Array.map (<anonymous>)
    	at d.initWatchers (/Users/username/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/out/client/extension.js:2:574507)
    	at async d.ensureWatchersReady (/Users/username/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/out/client/extension.js:2:536827)] {
      errno: -2,
      syscall: 'scandir',
      code: 'ENOENT',
      path: '/Users/username/Projects/project-name/.pixi/envs'
    }
    2024-07-09 14:41:13.122 [error] Dir "/Users/username/Projects/project-name/.pixi/envs" is not watchable (directory does not exist)
    2024-07-09 14:41:13.154 [info] Default formatter is set to null for workspace /Users/username/Projects/project-name
    2024-07-09 14:41:13.157 [info] Python interpreter path: ./.venv/bin/python
    2024-07-09 14:41:13.282 [info] > pyenv which python
    2024-07-09 14:41:13.282 [info] cwd: .
    2024-07-09 14:41:13.915 [info] > pixi --version
    2024-07-09 14:41:13.916 [error] [Error: spawn pixi ENOENT
    	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    	at onErrorNT (node:internal/child_process:484:16)
    	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
      errno: -2,
      code: 'ENOENT',
      syscall: 'spawn pixi',
      path: 'pixi',
      spawnargs: [ '--version' ]
    }
    2024-07-09 14:41:13.916 [warning] could not find a pixi interpreter for the interpreter at /Users/username/Projects/project-name/.venv/bin/python
    2024-07-09 14:41:14.487 [warning] could not find a pixi interpreter for the interpreter at /Users/username/Projects/project-name/.venv/bin/python
    2024-07-09 14:41:14.497 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/python_files/printEnvVariables.py
    2024-07-09 14:41:14.497 [info] shell: bash
    2024-07-09 14:41:14.527 [warning] could not find a pixi interpreter for the interpreter at /Users/username/Projects/project-name/.venv/bin/python
    2024-07-09 14:41:14.528 [info] > ./.venv/bin/python -m pytest -p vscode_pytest --collect-only tests
    2024-07-09 14:41:14.528 [info] cwd: .
    2024-07-09 14:41:14.657 [error] Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/pytest/__main__.py", line 5, in <module>
        raise SystemExit(pytest.console_main())
                         ^^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 192, in console_main
        code = main()
               ^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 150, in main
        
    2024-07-09 14:41:14.658 [error] config = _prepareconfig(args, plugins)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 331, in _prepareconfig
        config = pluginmanager.hook.pytest_cmdline_parse(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 265, in __call__
        return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 80, in _hookexec
        return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 55, in _multicall
        gen.send(outcome)
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/helpconfig.py", line 104, in pytest_cmdline_parse
        config: Config = outcome.get_result()
                         ^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/pluggy/_result.py", line 60, in get_result
        raise ex[1].with_traceback(ex[2])
    
    2024-07-09 14:41:14.658 [error]   File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 39, in _multicall
        res = hook_impl.function(*args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1075, in pytest_cmdline_parse
    
    2024-07-09 14:41:14.658 [error]     self.parse(args)
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1425, in parse
        self._preparse(args, addopts=addopts)
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1301, in _preparse
    
    2024-07-09 14:41:14.659 [error]     self.pluginmanager.consider_preparse(args, exclude_only=False)
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 709, in consider_preparse
    
    2024-07-09 14:41:14.659 [error]     self.consider_pluginarg(parg)
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 735, in consider_pluginarg
    
    2024-07-09 14:41:14.659 [error]     self.import_plugin(arg, consider_entry_points=True)
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 781, in import_plugin
    
    2024-07-09 14:41:14.659 [error]     __import__(importspec)
    
    2024-07-09 14:41:14.659 [error]   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
      File "/Users/username/Projects/project-name/.venv/lib/python3.12/site-packages/_pytest/assertion/rewrite.py", line 186, in exec_module
        exec(co, module.__dict__)
      File "/Users/username/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/python_files/vscode_pytest/__init__.py", line 895, in <module>
        class DeferPlugin:
      File "/Users/username/.vscode/extensions/ms-python.python-2024.10.0-darwin-arm64/python_files/vscode_pytest/__init__.py", line 896, in DeferPlugin
        @pytest.hookimpl(wrapper=True)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: HookimplMarker.__call__() got an unexpected keyword argument 'wrapper'
    
    2024-07-09 14:41:14.676 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/username/Projects/project-name.
    2024-07-09 14:41:14.677 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/username/Projects/project-name. Creating and sending error discovery payload
    2024-07-09 14:41:14.677 [error] pytest test discovery error for workspace:  /Users/username/Projects/project-name 
      
     The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /Users/username/Projects/project-name
  5. eleanorjboyd commented on Jul 9, 2024

    @eleanorjboyd
    Member

    Hi! What version of pytest are you using? It might be due to you being on a older version and updating might fix your problem.

  6. rafrafek commented on Jul 9, 2024

    @rafrafek

    Hi! I'm using version 7.4.4, and updating to the latest version 8.2.2 fixed the issue in my case. I'm not the author of this issue, though, so I would wait to confirm if it helps in that case.

  7. paulf81 commented on Jul 10, 2024

    @paulf81

    I have also had this issue

  8. jk1man1 commented on Jul 10, 2024

    @jk1man1

    I had the same problem. It seems that having the pytest verion 7.4.4, and updating to the latest version 8.2.2, fixed the issue on my end

  9. adam-lagoda commented on Jul 10, 2024

    @adam-lagoda
    Author

    I have now checked my environment package versions, and I had pytest running also running on 7.4.4, however, as jk1man1 and Rafał (@rafrafek) pointed out, 8.2.2 works out of the box. I have also tested, and 7.4.0 works as well.
    I am therefore closing this issue, as not relevant for vscode-python

  10. 46 remaining items

  11. toddsayersshell commented on Sep 25, 2024

    @toddsayersshell
  12. oldgithubman commented on Sep 26, 2024

    @oldgithubman
  13. anatesan-stream commented on Sep 26, 2024

    @anatesan-stream
  14. karthiknadig commented on Sep 26, 2024

    @karthiknadig
    Member

    We are actively investigating this. The short answer is, we are not able to isolate the issue. If we can't isolate it, we may have to revert pixi support. We want to avoid reverting pixi support which is a community contributed feature.

    If you are running into this, and it is blocking, pin the extension to a previous version.

    I will be marking anything that does not directly help us address this issue as off topic. I understand the frustration, we are investigating this. Off-topic comments are not helpful to get us to resolving this issue.

  15. zljubisic commented on Sep 27, 2024

    @zljubisic

    Karthik Nadig (@karthiknadig) If you want to isolate issue, create a new python project, install pytest, write a test and try to debug it. You will see that test is not found. Maybe it will brake after some number of tests, so you have to write more than one test.
    While vscode is braking, executing pytest from the shell works as expected.

  16. karthiknadig commented on Sep 27, 2024

    @karthiknadig
    Member

    zljubisic I have tried to repro this on few repos with 70k tests. Unfortunately, I can't repro it. the hypothesis is that it seems to be related some state of the environment that makes pixi categorize it as non conda.

    I have a build here where we prioritize the conda category over pixi. If this works then it means that the issue is with forming the activation commands that pixi takes over when. If this does not bypass it then we need to look further.

    Try pre-release version ms-python.python.2024.15.2024092702, it requires latest VS Code insiders.

  17. thethiny commented on Sep 30, 2024

    @thethiny

    zljubisic I have tried to repro this on few repos with 70k tests. Unfortunately, I can't repro it. the hypothesis is that it seems to be related some state of the environment that makes pixi categorize it as non conda.

    I have a build here where we prioritize the conda category over pixi. If this works then it means that the issue is with forming the activation commands that pixi takes over when. If this does not bypass it then we need to look further.

    Try pre-release version ms-python.python.2024.15.2024092702, it requires latest VS Code insiders.

    My code has no conda, has no pixi. Just main.py and tests/test_code.py

  18. karthiknadig commented on Sep 30, 2024

    @karthiknadig
    Member

    thethiny (@thethiny) Did you try with the ms-python.python.2024.15.2024092702 build to see what happens?

  19. AngelFP commented on Oct 1, 2024

    @AngelFP

    Karthik Nadig (@karthiknadig) I just happened to experience this issue today. I switched to the latest prerelease version (it says v2024.17.2024100102) and now the tests are working again.

  20. thethiny commented on Oct 1, 2024

    @thethiny

    thethiny (@thethiny) Did you try with the ms-python.python.2024.15.2024092702 build to see what happens?

    I updated to the latest release and it didn't work. Then I switched python to pre-release and they're working fine.

  21. zljubisic commented on Oct 1, 2024

    @zljubisic

    zljubisic I have tried to repro this on few repos with 70k tests. Unfortunately, I can't repro it. the hypothesis is that it seems to be related some state of the environment that makes pixi categorize it as non conda.

    I have a build here where we prioritize the conda category over pixi. If this works then it means that the issue is with forming the activation commands that pixi takes over when. If this does not bypass it then we need to look further.

    Try pre-release version ms-python.python.2024.15.2024092702, it requires latest VS Code insiders.

    Karthik Nadig (@karthiknadig) thank you for paying attention to this issue.
    Unfortunately, I can't update to VS Code insiders and also I wouldn't be happy with pre-lease version of the python extension.
    I am creating virtual environments using (mini)conda. I don't know if this helps.

  22. anthonykim1 commented on Oct 2, 2024

    @anthonykim1

    thethiny (@thethiny) ms-python.python.2024.15.2024092702 mentioned would be the pre-release version, so I think you are getting the expected result.

    Looks like #24198 helped re-prioritize conda over pixi. So people should really give a try on the latest PRE-release of the Python extension.

  23. anatesan-stream commented on Oct 2, 2024

    @anatesan-stream
  24. github-actions commented on Nov 2, 2024

    @github-actions

    Hey Anthony Kim (@anthonykim1), this issue might need further attention.

    Adam Lagoda (@adam-lagoda), you can help us out by closing this issue if the problem no longer exists, or adding more information.

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

Metadata

Metadata

Labels

info-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions