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 Alexandros Karypidis
Recipients Alexandros Karypidis, paul.moore, steve.dower, tim.golden, zach.ware
Date 2019-12-08.18:49:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1575830943.65.0.538772164668.issue38999@roundup.psfhosted.org>
In-reply-to
Content
When you activate a venv on Windows and use a shebang with a major verion qualifier, the python launcer does not properly detect that a venv is active and uses the system installation instead.

The incorrect behavior is documented in this SO question where another user has confirmed and suggested it is a bug: https://stackoverflow.com/questions/59238326

Steps to reproduce (needs script.py attached below):

1. Install Python 3.7 on Windows 10 (64 bit)
2. Run script.py you should see:
PS C:\pytest> .\script.py
EXECUTABLE: C:\Program Files\Python37\python.exe
PREFIX: C:\Program Files\Python37
BASE PREFIX: C:\Program Files\Python37

3. Create and activate a virtual environment with:
PS C:\pytest> python -m venv .venv
PS C:\pytest> . .\.venv\Scripts\Activate.ps1

4. Run script.py you should see it ignore the active virtual environment:
(.venv) PS C:\pytest> .\script.py
EXECUTABLE: C:\Program Files\Python37\python.exe
PREFIX: C:\Program Files\Python37
BASE PREFIX: C:\Program Files\Python37

I am using Windows 10 64-bit, update 1903 and Python 3.7.5-64
History
Date User Action Args
2019-12-08 18:49:03Alexandros Karypidissetrecipients: + Alexandros Karypidis, paul.moore, tim.golden, zach.ware, steve.dower
2019-12-08 18:49:03Alexandros Karypidissetmessageid: <1575830943.65.0.538772164668.issue38999@roundup.psfhosted.org>
2019-12-08 18:49:03Alexandros Karypidislinkissue38999 messages
2019-12-08 18:49:03Alexandros Karypidiscreate