This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Denis.Barmenkov, Jonathon Reinhart, Nicholas Brown, aikinci, antoine.pietri, arekm, bbi5291, christian.heimes, cinerar, eric.araujo, filippo, georg.brandl, grahamd, izbyshev, loewis, matrixise, nadeem.vawda, ned.deily, neologix, r.david.murray, serhiy.storchaka, surajd, tarek, vstinner, xuanji, yan12125, zaytsev
Date 2018-12-05.14:46:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> If I understood PR 10919 correctly, sysconfig.get_config_var('userbase') can now return unexpanded paths containing '~'. Is it intended despite the previous discussion starting with msg135047?

With my PR 10919, "python3 install" and  "python3 install --user" still fail with:

Traceback (most recent call last):
  File "", line 79, in <module>
  File "", line 75, in main
  File "/tmp/cpython/Lib/distutils/", line 121, in setup
  File "/tmp/cpython/Lib/distutils/", line 397, in parse_config_files
    filenames = self.find_config_files()
  File "/tmp/cpython/Lib/distutils/", line 349, in find_config_files
  File "/tmp/cpython/Lib/distutils/", line 161, in check_environ
    os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
KeyError: 'getpwuid(): uid not found: 12345'

I suggest to open a new issue if you want to enhance the error message and/or handle getpwuid() failure in find_config_files().

I prefer to stick to the initial bug report which hasn't been fixed in 8 years:

> When Python cannot find the home directory of the user invoking it, it prints "'import site' failed; use -v for traceback".

IMHO PR 10919 fix is straighforward, it respects the contract (documentation) of posixpath.expanduser() ("If user or $HOME is unknown, do nothing."), and expanduser() already handles KeyError on getpwnam() (since the function has been created in 1992 by Guido van Rossum! commit 7ac4878773040158038031a85be122d9e7071afe).
Date User Action Args
2018-12-05 14:46:02vstinnersetrecipients: + vstinner, loewis, georg.brandl, arekm, christian.heimes, nadeem.vawda, tarek, ned.deily, eric.araujo, grahamd, r.david.murray, neologix, filippo, xuanji, bbi5291, Denis.Barmenkov, aikinci, serhiy.storchaka, matrixise, zaytsev, antoine.pietri, yan12125, Jonathon Reinhart, surajd, izbyshev, cinerar, Nicholas Brown
2018-12-05 14:46:01vstinnersetmessageid: <>
2018-12-05 14:46:01vstinnerlinkissue10496 messages
2018-12-05 14:46:01vstinnercreate