<div dir="ltr">Hi,<div><br></div><div>Right; matplotlib expects matplotlibrc to be installed. Looking at <span style="color:rgb(0,0,0);font-size:12.8px">matplotlib/__init__.py, you can see </span>rc_params() calls matplotlib_fname() to get the default config filename.</div><div><br></div><div>The search order there is:</div><div>







<p class="gmail-p1"><span class="gmail-s1">    - `$PWD/matplotlibrc`</span></p>
<p class="gmail-p1"><span class="gmail-s1">    - `$MATPLOTLIBRC/matplotlibrc`</span></p>
<p class="gmail-p1"><span class="gmail-s1">    - `$MPLCONFIGDIR/matplotlibrc`</span></p><p class="gmail-p1"><span class="gmail-s1">          - `$HOME/.matplotlib/matplotlibrc`, if it exists</span></p><p class="gmail-p1"><span class="gmail-s1">          - or `$XDG_CONFIG_HOME/matplotlib/matplotlibrc` (if</span></p><p class="gmail-p1"><span class="gmail-s1">            $XDG_CONFIG_HOME is defined)</span></p><p class="gmail-p1"><span class="gmail-s1">          - or `$HOME/.config/matplotlib/matplotlibrc` (if</span></p><p class="gmail-p1"><span class="gmail-s1">            $XDG_CONFIG_HOME is not defined)</span></p><p class="gmail-p2"><span class="gmail-s1"></span></p><p class="gmail-p1"><span class="gmail-s1">         - `$HOME/.matplotlib/matplotlibrc` if `$HOME` is defined.</span></p><p class="gmail-p1"><span class="gmail-s1">    - Lastly, it looks in `$MATPLOTLIBDATA/matplotlibrc` for a</span></p><p class="gmail-p1"><span class="gmail-s1">




















</span></p><p class="gmail-p1"><span class="gmail-s1">      system-defined copy.</span></p><p class="gmail-p1"><span class="gmail-s1"><br></span></p><p class="gmail-p1">So just create a matplotlibrc in your $SNAP and you should be good</p><p class="gmail-p1">Cheers,</p><p class="gmail-p1">- Loïc</p>















</div>















</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 2, 2016 at 9:54 AM, Robert Park <span dir="ltr"><<a href="mailto:robert.park@canonical.com" target="_blank">robert.park@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all!<br>
<br>
Back again with a second attempt, this time I'm not trying to modify<br>
the host system so I'm hoping this should be a lot easier/possible!<br>
<br>
Here's my snapcraft.yaml:<br>
<br>
<a href="https://git.launchpad.net/~robru/+git/weightloss/tree/snapcraft.yaml" rel="noreferrer" target="_blank">https://git.launchpad.net/~<wbr>robru/+git/weightloss/tree/<wbr>snapcraft.yaml</a><br>
<br>
Pretty simple little flask webapp, just does some data manipulations<br>
and then serves graphics over HTTP.<br>
<br>
Snap builds ok but when I run it I get this:<br>
<br>
 weighttracker<br>
Traceback (most recent call last):<br>
  File "/snap/weighttracker/x2/run.<wbr>py", line 15, in <module><br>
    from graph import draw<br>
  File "/snap/weighttracker/x2/graph.<wbr>py", line 14, in <module><br>
    from matplotlib.dates import DateFormatter<br>
  File "/snap/weighttracker/x2/usr/<wbr>lib/python3/dist-packages/<wbr>matplotlib/__init__.py",<br>
line 1133, in <module><br>
    rcParams = rc_params()<br>
  File "/snap/weighttracker/x2/usr/<wbr>lib/python3/dist-packages/<wbr>matplotlib/__init__.py",<br>
line 977, in rc_params<br>
    return rc_params_from_file(fname, fail_on_error)<br>
  File "/snap/weighttracker/x2/usr/<wbr>lib/python3/dist-packages/<wbr>matplotlib/__init__.py",<br>
line 1102, in rc_params_from_file<br>
    config_from_file = _rc_params_in_file(fname, fail_on_error)<br>
  File "/snap/weighttracker/x2/usr/<wbr>lib/python3/dist-packages/<wbr>matplotlib/__init__.py",<br>
line 1020, in _rc_params_in_file<br>
    with _open_file_or_url(fname) as fd:<br>
  File "/snap/weighttracker/x2/usr/<wbr>lib/python3.5/contextlib.py", line<br>
59, in __enter__<br>
    return next(self.gen)<br>
  File "/snap/weighttracker/x2/usr/<wbr>lib/python3/dist-packages/<wbr>matplotlib/__init__.py",<br>
line 1005, in _open_file_or_url<br>
    with io.open(fname, encoding=encoding) as f:<br>
PermissionError: [Errno 13] Permission denied: '/etc/matplotlibrc'<br>
<br>
<br>
Not really sure what's going on, but it looks like matplotlib is<br>
hard-coding "/etc":<br>
<br>
$ cat /snap/weighttracker/x2/usr/<wbr>lib/python3/dist-packages/<wbr>matplotlib/__init__.py<br>
| grep /etc<br>
    path = '/etc'  # guaranteed to exist or raise<br>
<br>
<br>
Do I have to patch matplotlib here or is there some way snapcraft can<br>
fix this for me?<br>
<br>
(frustratingly the matplotlib code seems to harmlessly ignore the file<br>
if it doesn't exist, but they didn't anticipate the idea that they<br>
wouldn't have permission, so the code just barfs)<br>
<br>
<br>
<br>
Thanks.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
robru<br>
<br>
--<br>
Snapcraft mailing list<br>
<a href="mailto:Snapcraft@lists.snapcraft.io">Snapcraft@lists.snapcraft.io</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/snapcraft" rel="noreferrer" target="_blank">https://lists.ubuntu.com/<wbr>mailman/listinfo/snapcraft</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">- Loïc</div></div>
</div>