diff --git a/Lib/packaging/install.py b/Lib/packaging/install.py --- a/Lib/packaging/install.py +++ b/Lib/packaging/install.py @@ -13,7 +13,7 @@ import shutil import logging import tempfile -from sysconfig import get_config_var, get_path +from sysconfig import get_config_var, get_path, is_python_build from packaging import logger from packaging.dist import Distribution @@ -492,6 +492,12 @@ purelib_path = get_path('purelib') # trying to write a file there try: + if is_python_build(): + message = """You are running this from an uninstalled Python. +This likely implies that you are trying to install a 3rd-party package +without a working Python installation. That is unsupported.""" + logger.info(message) + return False with tempfile.NamedTemporaryFile(suffix=project, dir=purelib_path) as testfile: testfile.write(b'test')