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 Dieter Weber
Recipients Dieter Weber
Date 2019-01-10.14:04:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547129099.62.0.924394155356.issue35706@roundup.psfhosted.org>
In-reply-to
Content
Python virtual environments are awesome! Using venvs with an embedded Python interpreter has proven difficult, unfortunately. With conda environments it works. See appended a sample file to reproduce the behavior.

The core of the problem seems to be that a venv doesn't contain a full Python installation, and Py_Initialize() apparently doesn't support setting up the combination of venv directories and base installation correctly, i.e. setting sys.prefix and sys.base_prefix and potentially other values.

Observed behavior when trying to use a venv:

"""
Initializing... Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00001e90 (most recent call first):
"""

Expected behavior:
Setting Py_SetPythonHome() to a venv works and sets up all paths and prefixes correctly to use the venv, just like it does for a conda environment.
History
Date User Action Args
2019-01-10 14:05:02Dieter Webersetrecipients: + Dieter Weber
2019-01-10 14:04:59Dieter Webersetmessageid: <1547129099.62.0.924394155356.issue35706@roundup.psfhosted.org>
2019-01-10 14:04:59Dieter Weberlinkissue35706 messages
2019-01-10 14:04:59Dieter Webercreate