1 diff --git a/Lib/site.py b/Lib/site.py
4 @@ -262,7 +266,7 @@ def addusersitepackages(known_paths):
5 # this call will also make sure USER_BASE and USER_SITE are set
6 user_site = getusersitepackages()
8 - if ENABLE_USER_SITE and os.path.isdir(user_site):
9 + if ENABLE_USER_SITE and user_site and os.path.isdir(user_site):
10 addsitedir(user_site, known_paths)
13 diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
14 --- a/Lib/sysconfig.py
15 +++ b/Lib/sysconfig.py
16 @@ -170,7 +170,13 @@ def _expand_vars(scheme, vars):
17 for key, value in _INSTALL_SCHEMES[scheme].items():
18 if os.name in ('posix', 'nt'):
19 value = os.path.expanduser(value)
20 - res[key] = os.path.normpath(_subst_vars(value, vars))
22 + path = _subst_vars(value, vars)
23 + except AttributeError:
24 + # a substitution variable doesn't exist (eg. '{userbase}'),
25 + # don't create the variable
27 + res[key] = os.path.normpath(path)
30 def _get_default_scheme():
31 @@ -488,7 +494,12 @@ def get_config_vars(*args):
32 # Setting 'userbase' is done below the call to the
33 # init function to enable using 'get_config_var' in
35 - _CONFIG_VARS['userbase'] = _getuserbase()
37 + _CONFIG_VARS['userbase'] = _getuserbase()
39 + # catch getpwuid() error: don't create the variable if the user
43 if 'srcdir' not in _CONFIG_VARS:
44 _CONFIG_VARS['srcdir'] = _PROJECT_BASE