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

getpwuid(): uid not found: 99 #17707

Closed
fcomte opened this issue Jun 21, 2020 · 13 comments
Closed

getpwuid(): uid not found: 99 #17707

fcomte opened this issue Jun 21, 2020 · 13 comments

Comments

@fcomte
Copy link

fcomte commented Jun 21, 2020

Hello

I am using a container image of tensorflow.
Inside it, the uid is 99 and there is no user map to it in /etc/passwd

I get the following error when I import matplotlib "getpwuid(): uid not found: 99"
Name: matplotlib
Version: 3.2.1

@jklymak
Copy link
Member

jklymak commented Jun 21, 2020

Can you provide the full traceback. We do not call getpwuid().

@jklymak jklymak added the status: needs clarification Issues that need more information to resolve. label Jun 21, 2020
@fcomte
Copy link
Author

fcomte commented Jun 21, 2020

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/lib/python3.6/pathlib.py in gethomedir(self, username)
    359             try:
--> 360                 return os.environ['HOME']
    361             except KeyError:

/usr/lib/python3.6/os.py in __getitem__(self, key)
    668             # raise KeyError with the original key value
--> 669             raise KeyError(key) from None
    670         return self.decodevalue(value)

KeyError: 'HOME'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-1-0484cd13f94d> in <module>
----> 1 import matplotlib

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in <module>
   1013 
   1014 # this is the instance used by the matplotlib classes
-> 1015 rcParams = rc_params()
   1016 
   1017 

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in rc_params(fail_on_error)
    876 def rc_params(fail_on_error=False):
    877     """Construct a `RcParams` instance from the default Matplotlib rc file."""
--> 878     return rc_params_from_file(matplotlib_fname(), fail_on_error)
    879 
    880 

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in matplotlib_fname()
    729         yield os.path.join(_get_data_path(), 'matplotlibrc')
    730 
--> 731     for fname in gen_candidates():
    732         if os.path.exists(fname) and not os.path.isdir(fname):
    733             return fname

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in gen_candidates()
    726             yield matplotlibrc
    727             yield os.path.join(matplotlibrc, 'matplotlibrc')
--> 728         yield os.path.join(get_configdir(), 'matplotlibrc')
    729         yield os.path.join(_get_data_path(), 'matplotlibrc')
    730 

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in wrapper(**kwargs)
    274         nonlocal called, ret
    275         if not called:
--> 276             ret = func(**kwargs)
    277             called = True
    278             _log.debug(fmt, ret)

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in get_configdir()
    607     5. A writable directory could not be found or created; return None.
    608     """
--> 609     return _get_config_or_cache_dir(_get_xdg_config_dir())
    610 
    611 

/usr/local/lib/python3.6/dist-packages/matplotlib/__init__.py in _get_xdg_config_dir()
    560     <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
    561     """
--> 562     return os.environ.get('XDG_CONFIG_HOME') or str(Path.home() / ".config")
    563 
    564 

/usr/lib/python3.6/pathlib.py in home(cls)
   1060         returned by os.path.expanduser('~')).
   1061         """
-> 1062         return cls(cls()._flavour.gethomedir(None))
   1063 
   1064     def samefile(self, other_path):

/usr/lib/python3.6/pathlib.py in gethomedir(self, username)
    361             except KeyError:
    362                 import pwd
--> 363                 return pwd.getpwuid(os.getuid()).pw_dir
    364         else:
    365             import pwd

KeyError: 'getpwuid(): uid not found: 99'

@jklymak
Copy link
Member

jklymak commented Jun 21, 2020

So with your setup you cannot even call Path.home() from the standard library. I'm not clear what the point of such a setup is, or if its reasonable for us to support. Perhaps @anntzer or @tacaswell would know better.

@tacaswell
Copy link
Member

This can probably be fixed via the container configuration in the short run, but this is something that we should support gracefully.

@fcomte
Copy link
Author

fcomte commented Jun 21, 2020

I am using mesos universal container runtime .. this is why it is not really easy to solve in container runtime

@tacaswell
Copy link
Member

The function that is failing (https://docs.python.org/3/library/pwd.html#pwd.getpwuid) is trying to look up information about the user that is currently running. I am not convinced that this should be expected to fail in a properly configured container (but I am not an expert sysadmin).

@fcomte
Copy link
Author

fcomte commented Jun 22, 2020

It should not fail indeed

@QuLogic
Copy link
Member

QuLogic commented Jun 22, 2020

I don't understand why, if you can't fix /etc/passwd, you can't set HOME before running your script?

@timhoffm
Copy link
Member

Configuration aside, IMHO, Path.home() should not raise this KeyError (https://bugs.python.org/issue41082).

@fcomte
Copy link
Author

fcomte commented Jun 23, 2020

I don't understand why, if you can't fix /etc/passwd, you can't set HOME before running your script?

I fix /etc/passwd with a new docker image from the previous one, but i am still surprised by this behaviour in such a scenario

@QuLogic QuLogic added status: upstream fix required and removed status: needs clarification Issues that need more information to resolve. labels Jul 7, 2020
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Aug 7, 2023
@tacaswell
Copy link
Member

We should be defensively catching an exceptions that may be raised on import as they are non-recoverable by the user.

@tacaswell tacaswell modified the milestones: v3.8.0, v3.9.0 Aug 7, 2023
@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label Aug 9, 2023
@tacaswell
Copy link
Member

With mpl 3.9 will require python 3.10 which fixes this bug upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants