[New-bugs-announce] [issue39439] Windows Multiprocessing in Virtualenv: sys.prefix is incorrect

Adam Meily report at bugs.python.org
Thu Jan 23 16:04:50 EST 2020


New submission from Adam Meily <meily.adam at gmail.com>:

I upgraded from Python 3.7.1 to 3.7.6 and began noticing a behavior that was breaking my code. My code detects if it's running in a virtualenv. This check worked in 3.7.1 but is broken in 3.7.6.

>From the documentation, sys.prefix and sys.exec_prefix should point to the virtualenv when one is active. However, I'm seeing that both of these constants are pointing to the system installation directory and not my virtualenv when I am in a multiprocessing child. Here is an example output of a test application running in 3.7.6 (I've attached the test script to this ticket):

Parent process
=============================================
sys.prefix:           C:\Users\user\project\venv
sys.exec_prefix:      C:\Users\user\project\venv
sys.base_prefix:      C:\Program Files\Python37
sys.base_exec_prefix: C:\Program Files\Python37
=============================================

Subprocess
=============================================
sys.prefix:           C:\Program Files\Python37
sys.exec_prefix:      C:\Program Files\Python37
sys.base_prefix:      C:\Program Files\Python37
sys.base_exec_prefix: C:\Program Files\Python37
=============================================


I would expect that sys.prefix and sys.exec_prefix to be identical in the parent and child process.

I verified that this behavior is present in 3.7.5, 3.7.6, and 3.8.1. I am on a Windows 10 x64 system.

Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32

----------
components: Windows
files: multiproc_venv_prefix.py
messages: 360581
nosy: meilyadam, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Windows Multiprocessing in Virtualenv: sys.prefix is incorrect
versions: Python 3.7, Python 3.8
Added file: https://bugs.python.org/file48862/multiproc_venv_prefix.py

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


More information about the New-bugs-announce mailing list