Skip to content

Commit 9b789e5

Browse files
[3.11] gh-96861: Check for unset sys.executable during venv creation. (GH-96887) (GH-96919)
(cherry picked from commit 2cd70ff)
1 parent 1448e2a commit 9b789e5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/venv/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ def create_if_needed(d):
128128
context.prompt = '(%s) ' % prompt
129129
create_if_needed(env_dir)
130130
executable = sys._base_executable
131+
if not executable: # see gh-96861
132+
raise ValueError('Unable to determine path to the running '
133+
'Python interpreter. Provide an explicit path or '
134+
'check that your PATH environment variable is '
135+
'correctly set.')
131136
dirname, exename = os.path.split(os.path.abspath(executable))
132137
context.executable = executable
133138
context.python_dir = dirname

0 commit comments

Comments
 (0)