I have a Python script that starts like this:
#!/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
It works like a charm, but my editor complains: E402 module level import not at top of file [pep8]
.
If I move the matplotlib.use("Agg")
down, the script will not work.
Should I just ignore the error? Or is there a way to fix this?
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.
(I'm using Atom with linter-pylama.)