[New-bugs-announce] [issue35873] Controlling venv from venv no longer works in 3.7.2

Marc Schlaich report at bugs.python.org
Fri Feb 1 04:03:04 EST 2019


New submission from Marc Schlaich <marc.schlaich at googlemail.com>:

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 (https://github.com/pipxproject/pipx-app) 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; subprocess.run(['C:\Users\$USER\.local\pipx\venvs\tox\Scripts\python.exe', '-m', 'pip', 'install', 'tox'])"


Downstream bugreport in pipx is https://github.com/pipxproject/pipx-app/issues/81.

----------
components: Library (Lib), Windows
messages: 334659
nosy: paul.moore, schlamar, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Controlling venv from venv no longer works in 3.7.2
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35873>
_______________________________________


More information about the New-bugs-announce mailing list