This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steve.dower
Recipients docs@python, eryksun, gaborjbernat, keller00, paul.moore, steve.dower, tim.golden, vinay.sajip, zach.ware
Date 2020-10-15.11:51:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1602762697.7.0.410708965914.issue42041@roundup.psfhosted.org>
In-reply-to
Content
This is due to how Windows resolves relative paths when creating a new process. It *always* looks in the current application directory first, which with this setup will be the original Python executable rather than the venv redirector.

The best fix is to pass sys.executable instead of "python", which is more reliable on every OS and under every configuration. I've heard multiple people say that they prefer to launch venvs directly rather than modifying their environment in order to put it first on PATH.

If you are deliberately trying to use PATH to resolve the user's default "python" (which may not be in any way related to the one that's currently running), then use shutil.which() first and pass the full path to subprocess.

There's no bug to fix here, but if someone wants to add a section to the docs (and ideally, Mark or someone who has hit this problem can tell us which docs they read where they might have seen it) explaining that passing "python" to subprocess is a bad idea, feel free.
History
Date User Action Args
2020-10-15 11:51:37steve.dowersetrecipients: + steve.dower, paul.moore, vinay.sajip, tim.golden, docs@python, zach.ware, eryksun, gaborjbernat, keller00
2020-10-15 11:51:37steve.dowersetmessageid: <1602762697.7.0.410708965914.issue42041@roundup.psfhosted.org>
2020-10-15 11:51:37steve.dowerlinkissue42041 messages
2020-10-15 11:51:37steve.dowercreate