danioxoli / HotSpotAnalysis_Plugin

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

Installing Hotspot Analysis plugin on QGIS 3.10.5 on MacOS #49

Open dondealban opened 4 years ago

dondealban commented 4 years ago

Hi Daniele,

Thank you (and your colleagues, MA Zurbarán, S Shaji, and AK Muthusamy) for your great efforts in developing the Hotspot Analysis plugin, which is a very useful tool for spatial clustering and analysis implemented in QGIS.

At first, I had an issue installing the plugin for QGIS 3.10.5 (all-in-one, long-term release, signed installer) on MacOS 10.15.4 (Catalina). I had the same issue regarding installation, similar to the previous issues submitted by gariochquine and biancaglez, among others. But after looking through the available documentation, I was finally successful in installing the plugin on my machine. I wanted to post this issue here, outlining the steps I made to help other users (who also encounter the same installation issues with these same settings) successfully complete their installation.

I installed the plugin by following the installation instructions for MacOS in the README, particularly installing PySAL 1.14.3, numpy, and, scipy using pip3 via the Terminal, all of which were installed in this directory /Library/Python/3.7/site-packages/. After installing the required dependencies, I proceeded to install the plugin through the QGIS Plugin Manager, which was where I encountered the error as follows:

Couldn't load plugin 'HotspotAnalysis' due to an error when calling its classFactory() method 

ModuleNotFoundError: No module named 'pysal.esda' 
Traceback (most recent call last):
  File "/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 334, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/Users/dondealban/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/HotspotAnalysis/__init__.py", line 34, in classFactory
    from .hotspot_analysis import HotspotAnalysis
  File "/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/dondealban/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/HotspotAnalysis/hotspot_analysis.py", line 39, in 
    from pysal.esda.getisord import *
  File "/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'pysal.esda'

Python version: 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)] 
QGIS version: 3.10.5-A Coruña A Coruña, 984615fe1e

So I went back to the reported issues regarding the plugin in the past and found the answer in your previous responses, particularly in 14 March 2018 and in 31 Jan 2020. Indeed, the problem was that QGIS could not find PySAL within the Python environment that it was using, which I found out after importing PySAL from the Python console of QGIS.

Hence, I then tried to install PySAL again, but this time into the Python environment used by QGIS. I used the following command via the Terminal:

$ pip3 install -U pysal==1.14.3 -t /Applications/QGIS3.10.app/Contents/Resources/python/

This resulted in the following Terminal log:

Collecting pysal==1.14.3
Collecting numpy>=1.3 (from pysal==1.14.3)
  Using cached https://files.pythonhosted.org/packages/64/1e/982848d4e7b57ed06fbaed251a94d592cc59ebba83e454028f33866d4911/numpy-1.18.4-cp37-cp37m-macosx_10_9_x86_64.whl
Collecting scipy>=0.11 (from pysal==1.14.3)
  Using cached https://files.pythonhosted.org/packages/85/7a/ae480be23b768910a9327c33517ced4623ba88dc035f9ce0206657c353a9/scipy-1.4.1-cp37-cp37m-macosx_10_6_intel.whl
Installing collected packages: numpy, scipy, pysal
Successfully installed numpy-1.18.4 pysal-1.14.3 scipy-1.4.1

Afterwards, I attempted to install the plugin again in QGIS via the Plugin Manager, and finally the Hotspot Analysis plugin worked. Here is the screenshot of the plugin running in QGIS:

qgis hotspot analysis plugin

I hope these steps will be able to help other users in successfully installing the plugin for QGIS on MacOS.

danioxoli commented 4 years ago

Thank you for sharing!

FYI We are now working on the porting of the plugin to PySAL2. We found out that the current QGIS LTR (3.10) for macOS comes already with this library version in the core QGIS libraries. Therefore, it seems that there is no more need for macOS users to pass through the boring dependencies installation procedure requested by the current plugin version (see: https://github.com/danioxoli/HotSpotAnalysis_Plugin/blob/qgis3pysal2/README.md). For now, this is valid only on macOS while Linux and Windows distributions are still lacking PySAL2.

Best,

Daniele