From 5a190aca86b78e54e127f6e8111c0cbdd18eac38 Mon Sep 17 00:00:00 2001 From: Milan Straka Date: Fri, 4 Dec 2020 11:05:21 +0100 Subject: [PATCH] Only use site.USER_SITE is ENABLE_USER_SITE is set Fixes loading packages from user site even in a virtual environment. Should fix #42978. --- tensorflow/api_template.__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/api_template.__init__.py b/tensorflow/api_template.__init__.py index 99a278a14a4..a1c2ce5eb6a 100644 --- a/tensorflow/api_template.__init__.py +++ b/tensorflow/api_template.__init__.py @@ -116,7 +116,8 @@ from tensorflow.python.lib.io import file_io as _fi # Get sitepackages directories for the python installation. _site_packages_dirs = [] -_site_packages_dirs += [] if _site.USER_SITE is None else [_site.USER_SITE] +if _site.ENABLE_USER_SITE and _site.USER_SITE is not None: + _site_packages_dirs += [_site.USER_SITE] _site_packages_dirs += [_p for _p in _sys.path if 'site-packages' in _p] if 'getsitepackages' in dir(_site): _site_packages_dirs += _site.getsitepackages()