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

Subprocess with visual studio debugger attached to process causes a problem in python project #7514

Open
vsfeedback opened this issue Apr 12, 2023 · 2 comments
Assignees
Labels
needs investigation Could be an issue - needs investigation

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


I'm facing a very annoying issue with Visual Studio 2022. Here's how to replicate it.

Folder contents:

test-debugpy-issue
|   test-debugpy-issue.sln
|   
\---test-debugpy-issue
        cli.py
        environment.json
        test-debugpy-issue.pyproj
        test_debugpy_issue.py
        test_debugpy_issue_simplified.py

Contents of cli.py:

print("hello world")

Contents of test_debugpy_issue_simplified:

import subprocess
import os
import json

print(os.getpid())
input()

configArgs = ["python", "cli.py"]

ret_code=0
while ret_code==0:
    ret_code = subprocess.call(configArgs, shell=False, universal_newlines=True)
    print(ret_code)

In order to replicate the issue, carry out the following steps:

  • Open up a Powershell or CMD terminal
  • Run python .\test_debugpy_issue.py
  • Copy the provided PID
  • In Visual Studio 2022 under Debug > Attach to Process, paste the PID, select the process as shown below:

[! [enter image description here] 1] 1

  • Click Attach, then wait in the Output window until the process has successfully attached. This apparently requires multiple attempts:

[! [enter image description here] 2] 2

  • Go back into your Powershell and CMD terminal and press Enter
  • The following error should appear:

0.47s - Error importing debugpy._vendored.force_pydevd (with sys.path entry: 'c:\program > files\microsoft visual studio\2022\professional\common7\ide\extensions\microsoft\python\core')
Traceback (most recent call last):
File "c:\program files\microsoft visual studio\2022\professional\common7\ide\extensions\microsoft\python\core\debugpy_vendored\pyde> vd_pydevd_bundle\pydevd_defaults.py", line 60, in on_pydb_init
import(module_name)
ModuleNotFoundError: No module named 'debugpy'

I've found this issue on Github which describes a similar problem, but it's from the Vs Code repo. I'm not using VS Code.

Why is this happening and how can I fix it ?


Original Comments

Feedback Bot on 4/7/2023, 01:36 AM:

(private comment, text removed)


Original Solutions

(no solutions)

@StellaHuang95
Copy link
Contributor

@int19h Could you help taking a look at this one whenever you got a chance? Thanks.😊

@StellaHuang95 StellaHuang95 added needs investigation Could be an issue - needs investigation and removed needs triage labels Apr 14, 2023
@amine-aboufirass
Copy link

@StellaHuang95 thanks, I had also logged a similar issue for VS Code so that might be related, since I think both IDE's use debugpy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Could be an issue - needs investigation
Projects
None yet
Development

No branches or pull requests

4 participants