matplotlib.use required before other imports clashes with pep8. Ignore or fix?
<p>I have a pythonscript that starts like this:</p>

<pre><code>#!/usr/bin/env python
import matplotlib
matplotlib.use("Agg")

from matplotlib.dates import strpdate2num
import numpy as np
import pylab as pl
from cmath import rect, phase
</code></pre>

<p>It works like a charm, but my editor complains: <code>E402 module level import not at top of file [pep8]</code>.</p>

<p>If I move the <code>matplotlib.use("Agg")</code> down, the script will not work.</p>

<p>Should I just ignore the error? Or is there a way to fix this?</p>

<p><strong>EDIT :</strong> I'm aware that PEP8 says that this is only a suggestion and it may be ignored, but I'm hoping that there exists a nice way to initialise modules without breaking PEP8 guidelines, as I don't think I can make my editor ignore this rule on a per-file-basis.</p>

<p><strong>EDIT2 :</strong> I'm using Atom with linter-pylama</p>

<p>The solution depends on the <code>linter</code> that is being used. </p>

<p>In my case I am using <code>pylama</code> </p>

<p>The manual for this <code>linter</code> suggests adding <code># noqa</code> to the end of a line containing an error you wish to suppress.</p>

<p>Other linters will have different mechanisms.</p>

python matplotlib pep8