René's URL Explorer Experiment


Title: Nested subprocess `python -m ...` fails module resolution only when parent is launched via debugpy · Issue #2002 · microsoft/debugpy · GitHub

Open Graph Title: Nested subprocess `python -m ...` fails module resolution only when parent is launched via debugpy · Issue #2002 · microsoft/debugpy

X Title: Nested subprocess `python -m ...` fails module resolution only when parent is launched via debugpy · Issue #2002 · microsoft/debugpy

Description: Summary In a Windows project with src/ layout, a parent Python module runs correctly under debugpy, but a child subprocess started from that parent with: python -m my_tools.tasks.validation.main fails with: No module named my_tools.tasks...

Open Graph Description: Summary In a Windows project with src/ layout, a parent Python module runs correctly under debugpy, but a child subprocess started from that parent with: python -m my_tools.tasks.validation.main fa...

X Description: Summary In a Windows project with src/ layout, a parent Python module runs correctly under debugpy, but a child subprocess started from that parent with: python -m my_tools.tasks.validation.main fa...

Opengraph URL: https://github.com/microsoft/debugpy/issues/2002

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Nested subprocess `python -m ...` fails module resolution only when parent is launched via debugpy","articleBody":"## Summary\n\nIn a Windows project with `src/` layout, a parent Python module runs correctly under `debugpy`, but a child subprocess started from that parent with:\n\n```bash\npython -m my_tools.tasks.validation.main\n```\n\nfails with:\n\n```text\nNo module named my_tools.tasks.validation.main\n```\n\nThe exact same child command succeeds outside debugpy (normal terminal/task run).\n\n---\n\n## Environment\n\n- OS: Windows (PowerShell)\n- Python: virtualenv interpreter (`.venv\\Scripts\\python.exe`), debugpy 1.8.19\n- VS Code Python extension (debugpy launcher used by VS Code)\n- Project layout: `src/my_tools/...`\n- `PYTHONPATH` in launch config: `\u003cworkspace>/src`\n\n---\n\n## Expected behavior\n\nIf parent process is launched via debugpy and parent starts child with:\n\n```bash\n\u003cvenv_python> -m my_tools.tasks.validation.main ...\n```\n\nthen child should resolve and execute module exactly as in terminal mode.\n\n---\n\n## Actual behavior\n\nWhen parent is launched via debugpy (`module` launch in `launch.json`), child subprocess fails:\n\n```text\nNo module named my_tools.tasks.validation.main\n```\n\nWhen parent is launched normally (no debugpy), same child command succeeds.\n\n---\n\n## Reproduction pattern\n\n### Parent debug launch (fails in child)\n\nVS Code launch command shape:\n\n```text\n\u003cvenv>\\python.exe \u003c...>\\debugpy\\launcher \u003cport> -- -m my_tools.service.runner.main ...\n```\n\nInside parent:\n\n```python\ncmd = [\n    sys.executable,\n    \"-m\",\n    \"my_tools.tasks.validation.main\",\n    \"--help\",\n]\nsubprocess.run(\n    cmd,\n    cwd=\"\u003cworkspace>\",\n    env=env_with_pythonpath,\n    capture_output=True,\n    text=True,\n)\n```\n\nResult under debug launch:\n\n```text\nstderr: No module named my_tools.tasks.validation.main\n```\n\n### Parent non-debug launch (works)\n\n```bash\npython -m my_tools.service.runner.main ...\n```\n\nResult: child module resolves and completes successfully.\n\n### Manual debugpy CLI launch (also fails)\n\nAfter installing `debugpy` into the same venv, launching parent via CLI debugpy reproduces the same child failure:\n\n```bash\npython -m debugpy --listen 5678 -m my_tools.service.runner.main --queue-root \u003c...> --work-root \u003c...> --once --log-level DEBUG\n```\n\nResult:\n\n```text\nstderr: No module named my_tools.tasks.validation.main\n```\n\n---\n\n## Sanity checks already done\n\nAll of the following succeed in same venv:\n\n```bash\npython -c \"import os,sys,importlib.util as u,my_tools; print(sys.executable); print(os.getenv('PYTHONPATH')); print(u.find_spec('my_tools.tasks.validation.main'))\"\n```\n\n`find_spec(...)` returns valid `ModuleSpec` under `\u003cworkspace>/src/my_tools/...`.\n\nAlso succeeds:\n\n```bash\npython -c \"import os,sys,subprocess; env=os.environ.copy(); env['PYTHONPATH']=r'\u003cworkspace>\\\\src;\u003cworkspace>/src'; cmd=[sys.executable,'-m','my_tools.tasks.validation.main','--help']; r=subprocess.run(cmd,cwd=r'\u003cworkspace>',env=env,capture_output=True,text=True); print(r.returncode); print(r.stderr)\"\n```\n\nReturn code is `0`, stderr empty.\n\n---\n\n## Why this looks debugpy-related\n\n- Same interpreter path.\n- Same module path.\n- Same child command works outside debugpy.\n- Failure appears when parent is launched via debugpy (VS Code launcher and manual `python -m debugpy`).\n- The failing point is nested child module resolution via `-m`.\n\n---\n\n## Current workaround\n\n- Run parent as normal task/terminal (non-debug) for production-like execution.\n- Alternative code workaround: launch child by script path instead of `-m`, e.g.:\n\n```bash\npython \u003cworkspace>/src/my_tools/tasks/validation/main.py ...\n```\n\n---\n\n## Question to maintainers\n\nIs this a known issue/limitation with:\n\n- debugpy launcher + nested subprocess `-m` calls\n- `src/` layout + `PYTHONPATH`\n- Windows-specific env/path propagation\n\nand is there a recommended debugpy setting to make nested child `-m` module resolution deterministic?\n","author":{"url":"https://github.com/michaeltufar","@type":"Person","name":"michaeltufar"},"datePublished":"2026-03-04T14:14:43Z","url":"https://github.com/microsoft/debugpy/issues/2002"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7bb2b6b7-0c64-6444-b268-5dcdb5b5685a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD1EC:2EC4C2:B8248:102596:6AFE8D9B
html-safe-noncefd784219c778da6102588bf6cacd1e8a9a789dac9d33bcbe6f1541daca12b2f2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUVDOjJFQzRDMjpCODI0ODoxMDI1OTY6NkFGRThEOUIiLCJ2aXNpdG9yX2lkIjoiMTkxNjQ0MzIwNzAyNTk4Njk3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf603420bf3dd3a3709b194c2bce3984f93b4463d03fb80b0ae5daa770e2fb64b
hovercard-subject-tagissue:4022231060
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/debugpy/2002/issue_layout
twitter:imagehttps://opengraph.githubassets.com/028f2cdbdf78658436460a7985b8c14a8dde73a60aa706d736f3b24f95af58ae/microsoft/debugpy/issues/2002
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/028f2cdbdf78658436460a7985b8c14a8dde73a60aa706d736f3b24f95af58ae/microsoft/debugpy/issues/2002
og:image:altSummary In a Windows project with src/ layout, a parent Python module runs correctly under debugpy, but a child subprocess started from that parent with: python -m my_tools.tasks.validation.main fa...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemichaeltufar
hostnamegithub.com
expected-hostnamegithub.com
Noneb3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86
turbo-cache-controlno-preview
go-importgithub.com/microsoft/debugpy git https://github.com/microsoft/debugpy.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id234187391
octolytics-dimension-repository_nwomicrosoft/debugpy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id234187391
octolytics-dimension-repository_network_root_nwomicrosoft/debugpy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4a10310af51a1bfffbedc4fd81cb582acf0cb0ff
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/debugpy/issues/2002#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdebugpy%2Fissues%2F2002
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdebugpy%2Fissues%2F2002
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2Fdebugpy
Reloadhttps://github.com/microsoft/debugpy/issues/2002
Reloadhttps://github.com/microsoft/debugpy/issues/2002
Reloadhttps://github.com/microsoft/debugpy/issues/2002
microsofthttps://github.com/microsoft
debugpyhttps://github.com/microsoft/debugpy
Codehttps://github.com/microsoft/debugpy
Issues206 (206)https://github.com/microsoft/debugpy/issues
Pull requests15 (15)https://github.com/microsoft/debugpy/pulls
Discussionshttps://github.com/microsoft/debugpy/discussions
Actionshttps://github.com/microsoft/debugpy/actions
Projectshttps://github.com/microsoft/debugpy/projects
Wikihttps://github.com/microsoft/debugpy/wiki
Security and qualityhttps://github.com/microsoft/debugpy/security
Insightshttps://github.com/microsoft/debugpy/insights
https://github.com/microsoft/debugpy
New issuehttps://github.com/login?return_to=https://github.com/microsoft/debugpy/issues/2002
New issuehttps://github.com/login?return_to=https://github.com/microsoft/debugpy/issues/2002
Nested subprocess python -m ... fails module resolution only when parent is launched via debugpyhttps://github.com/microsoft/debugpy/issues/2002#top
https://github.com/michaeltufar
Michael Tufar (michaeltufar)https://github.com/michaeltufar
on Mar 4, 2026https://github.com/microsoft/debugpy/issues/2002#issue-4022231060
https://github.com/rchiodo
Rich Chiodo (rchiodo)https://github.com/rchiodo
on Mar 4, 2026https://github.com/microsoft/debugpy/issues/2002#issuecomment-3998975369
https://github.com/falkben
Ben Falk (falkben)https://github.com/falkben
on Apr 21, 2026https://github.com/microsoft/debugpy/issues/2002#issuecomment-4291644570
#1997https://github.com/microsoft/debugpy/issues/1997
https://github.com/falkben
Ben Falk (falkben)https://github.com/falkben
on Apr 21, 2026https://github.com/microsoft/debugpy/issues/2002#issuecomment-4291647483
Michael Tufar (@michaeltufar)https://github.com/michaeltufar
https://github.com/michaeltufar
Michael Tufar (michaeltufar)https://github.com/michaeltufar
on Apr 22, 2026https://github.com/microsoft/debugpy/issues/2002#issuecomment-4295245904
#1997https://github.com/microsoft/debugpy/issues/1997
#1997https://github.com/microsoft/debugpy/issues/1997
@michaeltufarhttps://github.com/michaeltufar
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/debugpy/issues/2002
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/debugpy/issues/2002
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.