danioxoli / HotSpotAnalysis_Plugin

A QGIS plugin for hotspot analysis
GNU General Public License v3.0
55 stars 12 forks source link

Error msg running test_data example on Mac #13

Closed adrianBSAS closed 2 years ago

adrianBSAS commented 5 years ago

Hi, I am trying to use for the first time your Hot_Spot Analysis Plugin. I have been following the demo exercise , loading the shape file, so far so good. Filled the form according to the instructions using the suggested Fixed Distance Band for the example. Input the Output Shape File and press OK. I am getting the following error message from the Python Log Message Panel

2018-09-30T16:47:46 1 Traceback (most recent call last): File "/Users/admin/.qgis2/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 604, in run w = DistanceBand(t, threshold1, p=2, binary=False) File "/Library/Python/2.7/site-packages/PySAL-1.14.4.post2-py2.7.egg/pysal/weights/Distance.py", line 791, in init neighbors, weights = self._distance_to_W(ids) File "/Library/Python/2.7/site-packages/PySAL-1.14.4.post2-py2.7.egg/pysal/weights/Distance.py", line 892, in _distance_to_W weighted = self.dmat.power(self.alpha) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/sparse/base.py", line 440, in getattr raise AttributeError(attr + " not found") AttributeError: power not found

Any ideas ?

Thanks Adrian from Bs.As.

danioxoli commented 5 years ago

Dear Adrian,

Thank you for your interest. Do you get the same error also changing the input layer? (I guess you are using the test point shapefile). Just do a test to exclude that the problem is due to that.

If this is not produced by a bad formatting of the input, you should try to reinstall or downgrade the SciPy lib using the pip. The base.py script causes some problem between vesion 0.18 and 0.19. (see here)

Let me know if one of these above will solve your problem.

Best, Daniele

adrianBSAS commented 5 years ago

Dear Daniele Thanks for your answer. I have tried with another file with exactly the same error message. First I have to tell you that I am a basic user of Max Os X and fist time using Python. I have run "sudo easy_install scipy " command from the terminal with the following result: Searching for scipy Best match: scipy 0.13.0b1 scipy 0.13.0b1 is already the active version in easy-install.pth

Using /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python Processing dependencies for scipy Finished processing dependencies for scipy

I am not using version 018 or 019. It seems is using a Python System Library no QGIS Library is this correct ? Thanks Daniele

danioxoli commented 5 years ago

Try to use the pip by running in series the following command from the terminal: pip install --upgrade pip pip install --upgrade numpy pip install --upgrade scipy pip install --upgrade pysal (Be sure that you are upgrading the library on Python 2 if you are using QGIS 2 version, but it should be yet your default environment by looking at your previous answer)

Then, restart QGIS and try again with the demo data.

Let me know if the issue is solved.

Best Daniele

abuabara commented 5 years ago

If using QGIS 3.4 and Python 3.6.x, you need to use pip3. Be sure to update pip first. The -H install to all users (HOME), sometimes it matters on your system. Works for me, using MacOS 10.14

pip3 install --upgrade pip sudo -H pip3 install -U numpy sudo -H pip3 install -U scipy sudo -H pip3 install -U pysal

adrianBSAS commented 5 years ago

Hi I am running QGIS 2.18.24 on Mac OS 10.13 and Python 2.7 Do you recommend to upgrade to QGIS 3.4 and Python 3.6.x ?

abuabara commented 5 years ago

Hi I am running QGIS 2.18.24 on Mac OS 10.13 and Python 2.7 Do you recommend to upgrade to QGIS 3.4 and Python 3.6.x ?

Definitely. Version 3.4 has been fairly stable, and contains many new features. The search box is invaluable. I also appreciate the image quality on high resolution monitors (i'm using Apple). The only bug that I've been seen is in map composer, drag to grid is not working properly. Otherwise, super recommended upgrade.

adrianBSAS commented 5 years ago

Hi Daniele, before upgrading to QGIS 3.4 I want to try to solve this with my current version 2.14.3 and Python 2.7 I have run pip install --upgrade pip pip install --upgrade numpy pip install --upgrade scipy pip install --upgrade pysal

And then run the plugin with the demodata.

Here is the complete error message.

An error has occurred while executing Python code:

AttributeError: power not found Traceback (most recent call last): File "/Users/admin/.qgis2/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 592, in run w = DistanceBand(t, threshold=i, p=2, binary=False) File "/Library/Python/2.7/site-packages/PySAL-1.14.4.post2-py2.7.egg/pysal/weights/Distance.py", line 791, in init neighbors, weights = self._distance_to_W(ids) File "/Library/Python/2.7/site-packages/PySAL-1.14.4.post2-py2.7.egg/pysal/weights/Distance.py", line 892, in _distance_to_W weighted = self.dmat.power(self.alpha) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/sparse/base.py", line 440, in getattr raise AttributeError(attr + " not found") AttributeError: power not found

Python version: 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] QGIS version: 2.14.3-Essen Essen, exported

Python Path: /Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing /Applications/QGIS.app/Contents/MacOS/../Resources/python /Users/admin/.qgis2/python /Users/admin/.qgis2/python/plugins /Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins /Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7 /Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages /Library/Python/2.7/site-packages/numpy-override /Library/Python/2.7/site-packages/matplotlib-override /Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages /Library/Python/2.7/site-packages/PySAL-1.14.4.post2-py2.7.egg /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC /Library/Python/2.7/site-packages /Users/admin/.qgis2//python /Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools

It looks like I am using PySAL 1.14.4 and scipy 0.13 I am running MacOS 2.7 standard Python I havent installed Homebrew or any other Python version before, just QGIS installation instructions.

Adrian

danioxoli commented 5 years ago

This is an error that shown up often while playing with the pip and pysal updating. Actually, on MacOS I ever used the Anaconda and installed Pysal from there. Python comes along your OS therefore QGIS is exploiting the native env. Unfortunately these is not a generic issue but depends from your env and no general solution are available (as far as I know at least).

Is this happening also with data different from the demodata?

If yes, what I can suggest is to remove from your system Pysal and try a clean installation from scratch.

Daniele