summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2022-09-17 11:58:31 (GMT)
committerGitHub <noreply@github.com>2022-09-17 11:58:31 (GMT)
commit2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6 (patch)
tree667ce218a800fe0f67bcf1b45cc1e6f53c70c122
parent0b62964b044949ebd728305e802f99fa026cf2cd (diff)
downloadcpython-2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6.zip
cpython-2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6.tar.gz
cpython-2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6.tar.bz2
gh-96861: Check for unset sys.executable during venv creation. (GH-96887)
-rw-r--r--Lib/venv/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index f6b790e..034e3d4 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -128,6 +128,11 @@ class EnvBuilder:
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