Author schlamar
Recipients paul.moore, schlamar, steve.dower, tim.golden, zach.ware
Date 2019-02-01.09:03:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Controlling a venv from the python.exe from another venv does not work since 3.7.2 on Windows. This is probably related to the change

    bpo-34977: venv on Windows will now use a python.exe redirector rather than copying the actual binaries from the base environment.

This is obviously related to bpo-35872, but this could be a different bug.

When a Python script in a venv wants to control another venv by running commands like `another-venv\python.exe -m pip` with subprocess, python.exe is not referencing the other venv. It is referencing to the venv the script currently running from. This is probably because os.environ contains a '__PYVENV_LAUNCHER__' which is pointing to the venv from the script.

This can be reproduced with pipx ( by running

    pipx install --python "C:\Program Files (x86)\Python37-32\python.exe" --verbose tox

This results in pip installing to venvs\pipx-app and not in venvs\tox. 

I assume a simpler reproduction might be (but I cannot check this anymore as I'm back on 3.7.1 right now):

    C:\Program Files (x86)\Python37-32\python.exe -m venv C:\Users\$USER\.local\pipx\venvs\tox
    c:\users\$USER\.local\pipx\venvs\pipx-app\scripts\python.exe -c "import subprocess;['C:\Users\$USER\.local\pipx\venvs\tox\Scripts\python.exe', '-m', 'pip', 'install', 'tox'])"

Downstream bugreport in pipx is
Date User Action Args
2019-02-01 09:03:08schlamarsetrecipients: + schlamar, paul.moore, tim.golden, zach.ware, steve.dower
2019-02-01 09:03:04schlamarsetmessageid: <>
2019-02-01 09:03:04schlamarlinkissue35873 messages
2019-02-01 09:03:04schlamarcreate