Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'getpwuid(): uid not found: 5001' #5940

Closed
cancan101 opened this issue Jan 28, 2016 · 2 comments
Closed

KeyError: 'getpwuid(): uid not found: 5001' #5940

cancan101 opened this issue Jan 28, 2016 · 2 comments
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Milestone

Comments

@cancan101
Copy link
Contributor

I am trying to use matplotlib inside a Docker container running as non root. When I do I get the following:

$ docker run -u 5001  -it  4catalyzer/ipython python -c 'import matplotlib'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 1131, in <module>
    rcParams = rc_params()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 965, in rc_params
    fname = matplotlib_fname()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 794, in matplotlib_fname
    configdir = _get_configdir()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 649, in _get_configdir
    return _get_config_or_cache_dir(_get_xdg_config_dir())
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 626, in _get_config_or_cache_dir
    return _create_tmp_config_dir()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 555, in _create_tmp_config_dir
    tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
  File "/usr/lib/python2.7/getpass.py", line 158, in getuser
    return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 5001'

Potentially just have getpass.getuser() then fall back to the UID value.

@cancan101
Copy link
Contributor Author

Something like:

try:
    username = getpass.getuser()
except KeyError:
    username = str(os.getuid())
tempdir = os.path.join(tempdir, 'matplotlib-%s' % username)

@jenshnielsen
Copy link
Member

Looks good to me. Will you make that change in a Pull Request?

@tacaswell tacaswell added this to the 1.5.2 (Critical bug fix release) milestone Jan 30, 2016
@tacaswell tacaswell added the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Jan 30, 2016
cancan101 added a commit to cancan101/matplotlib that referenced this issue Feb 1, 2016
tristan0x pushed a commit to cta-lapp/docker-CTA_Analysis that referenced this issue Jun 1, 2017
mzur added a commit to biigle/core that referenced this issue Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Projects
None yet
Development

No branches or pull requests

3 participants