[issue17010] Windows launcher ignores active virtual environment

Bryan G. Olson report at bugs.python.org
Tue Jan 22 00:57:37 CET 2013


New submission from Bryan G. Olson:

Python 3.3 includes PEP 397, a Python launcher for Windows, and PEP 405, virtual environment support in core. Unfortunately the Windows launcher does not respect virtual environments. Even with with a virtual environment activated and the current directory at the virtual environment's root, the Windows launcher will start python with the system environment, not the active virtual environment.


To demo:

Install python 3.3 for windows.

Create a virtual environment:

  C:\>c:\Python33\Tools\Scripts\pyvenv.py c:\virtpy

Activate the virtual environment:

  C:\>virtpy\Scripts\activate.bat
  (virtpy) C:\>

Optionally cd to the virtual environment:

  (virtpy) C:\>cd virtpy
  (virtpy) C:\virtpy>

Start Python 3 with the new windows launcher:

  (virtpy) C:\virtpy>py -3
  Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>>

Check sys.path

  >>> import sys
  >>>
  >>> sys.path
  ['', 'C:\\Windows\\system32\\python33.zip', 'C:\\bin\\Python33\\DLLs', 'C:\\bin\\Python33\\lib', 'C:\\bin\\Python33', 'C:\\bin\\Python33\\lib\\site-packages']
  >>>


The worst effect I've found is that installation of a package with windows launcher, "py -3 setup.py install", will ignore the active virtual environment and will change the system Python environment. That's bad because users frequently employ virtual environments to isolate changes that could damage a system configuration.

----------
components: Installation, Windows
messages: 180362
nosy: bryangeneolson
priority: normal
severity: normal
status: open
title: Windows launcher ignores active virtual environment
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17010>
_______________________________________


More information about the Python-bugs-list mailing list