[Python-checkins] gh-96861: Check for unset sys.executable during venv creation. (GH-96887)

vsajip webhook-mailer at python.org
Sat Sep 17 07:58:39 EDT 2022


https://github.com/python/cpython/commit/2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6
commit: 2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6
branch: main
author: Vinay Sajip <vinay_sajip at yahoo.co.uk>
committer: vsajip <vinay_sajip at yahoo.co.uk>
date: 2022-09-17T12:58:31+01:00
summary:

gh-96861: Check for unset sys.executable during venv creation. (GH-96887)

files:
M Lib/venv/__init__.py

diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index f6b790e1b71a..034e3d420177 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -128,6 +128,11 @@ def create_if_needed(d):
         context.prompt = '(%s) ' % prompt
         create_if_needed(env_dir)
         executable = sys._base_executable
+        if not executable:  # see gh-96861
+            raise ValueError('Unable to determine path to the running '
+                             'Python interpreter. Provide an explicit path or '
+                             'check that your PATH environment variable is '
+                             'correctly set.')
         dirname, exename = os.path.split(os.path.abspath(executable))
         context.executable = executable
         context.python_dir = dirname



More information about the Python-checkins mailing list