ccrook / QGIS-Contour-Plugin

Contour plugin for QGIS - uses python matplotlib to generate contours of data on vector point data.
44 stars 13 forks source link

Contour error #18

Closed alejogm0520 closed 6 years ago

alejogm0520 commented 7 years ago

Hi, I've been trying to use this plugin, however I find this error:

The contour plugin is disabled as it requires python modules numpy, matplotlib, and shapely which are not all installed.

I'm using:

Someone knows how to fix it ?

Thanks!!!!

-Alejo

ccrook commented 7 years ago

Hi @alejogm0520

This error is generated from the following python code.

mplAvailable=True
try:
    import numpy as np
    import matplotlib as mpl
    import matplotlib.pyplot as plt
    from matplotlib.mlab import griddata
    from shapely.geometry import MultiLineString, MultiPolygon
except:
    mplAvailable=False

If you open the python console from the Plugin menu in QGIS and type in each of the import lines one by one, then one of them should give an error. That will tell you which python library is not importing as expected.

alejogm0520 commented 7 years ago

Hi @ccrook Thanks for the fast answer, but I'm afraid that all the libraries are fine, there is no error when import the libraries at the python console from QGis, and the error stilll happen. Thanks!

-Alejo

ccrook commented 7 years ago

@alejogm0520. Thanks for confirming this. I'm not sure how to proceed now though, as the error "contour plugin is disabled" only occurs if mplAvailable is False, and mplAvailable is only set by the code above. So if these imports do not result in an exception then the error should not be triggered.

Are you able to find and edit the contour.py file. If so then you could locate the code above and replace it with


...
except:
  raise
  mplAvailable=False

That way the contour plugin should fail to load and you should see the exception that caused the problem. Which would be useful to know in terms of fixing it.

basilrabi commented 7 years ago

it seems we have to install python-matplotlib-qt4. After installing, the issue seems fixed.

jcpayne commented 6 years ago

Can someone please explain how to install python-matplotlib-qt4, if that is indeed the problem?

ccrook commented 6 years ago

@jcpayne Before that it might be worth testing which import is failing. I suggest opening the python console and entering each of these lines in turn, and see which one fails. I'm not sure why matplotlib would require the qt4 component (especially as QGIS3 uses qt5). I suspect that this installation fixed some other missing component in matplotlib.

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.mlab import griddata
from shapely.geometry import MultiLineString, MultiPolygon
ccrook commented 6 years ago

This issue now closed - see #34