summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-18 20:53:04 (GMT)
committerGitHub <noreply@github.com>2022-09-18 20:53:04 (GMT)
commitf4be544a0317fba25fad1e8a13d7f9f2f58f177d (patch)
tree583478b0d0dbae3b9484093d7bb10f3be4154f24
parenta978e2fa199c4bd146d0ba17181ed6150f35ccbb (diff)
downloadcpython-f4be544a0317fba25fad1e8a13d7f9f2f58f177d.zip
cpython-f4be544a0317fba25fad1e8a13d7f9f2f58f177d.tar.gz
cpython-f4be544a0317fba25fad1e8a13d7f9f2f58f177d.tar.bz2
[3.10] gh-96861: Check for unset sys.executable during venv creation. (GH-96887) (GH-96918)
(cherry picked from commit 2cd70ffb3fe22d778d0bb6ec220fdf67dccc1be6) Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk> Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
-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 6f1af29..8852008 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -115,6 +115,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