Open caseykalman opened 2 years ago
After a few days of debugging, I hope this solution to installing HotSpotAnalysis_Plugin is valuable to someone. My initial error was a version of the Pysal “ModuleNotFoundError.” My solution generally was a key-mash of copy/paste of the Pysal folder until I created successful output without errors. I should point out I previously installed Anaconda Python 3 on my PC. I lack the skills or patience to confirm this interacts with my solution. To begin with, in Win10 I installed QGIS 3.20.0-2 using admin rights. Following a successful installation, I proceeded to instructions for a 3.20 installation of HotSpotAnalysis_Plugin (https://github.com/danioxoli/HotSpotAnalysis_Plugin). With admin rights, I opened a OSGeo4W shell. Within the command window, I executed the following commands in this order: 1) py3_env, 2) python -m pip install --upgrade pip, 3) python -m pip install pysal, 4) pip show pysal. This last command is to confirm installation of Pysal 2.0.0. Since I installed Pysal 2.0.0 (I’ll come to where in a moment), I downloaded the latest, unreleased version of HotSpotAnalysis_Plugin at its repository link (https://github.com/danioxoli/HotSpotAnalysis_Plugin/archive/refs/heads/qgis3pysal2.zip). As with any other QGIS plugin, I installed it using the ZIP file location option. Upon installation, QGIS produced the “ModuleNotFoundError” when looking for Pysal. Having just installed it, that was a perplexing answer. I should note there is probably a solution that involves telling QGIS of other Python libraries. As I said, my skills are limited. Instructions for overcoming this error suggest commenting out a “import spreg” command (among other ideas). Whereas the plugin code no longer contains this specific line of code and context, it appears that suggestion is not helpful (or necessary). In order to account for the problem of QGIS finding Pysal, I created a crude solution: 1) uninstall the HotSpotAnalysis plugin, 2) close QGIS, 3) copy “Pysal” and “seaborn” folders from “C:\OSGeo4W64\apps\Python37\lib\site-packages” to “C:\Program Files\QGIS 3.20.0\apps\qgis\python, 4) install HotSpotAnalysis plugin from the list of uninstalled plugins (do not use ZIP). No errors occurred in installation. As a test of the plugin I used the following data sets and instructions: 1) create a Getis Ord G SHP file from “demo_data” provided—success, 2) create a Getis Ord G SHP file from “demo_data_poly” provided—success, 3) create a Getis Ord G SHP file from a personal SHP file of all 2015 US ZIP codes using population by ZIP—fail, 4) create a Getis Ord G SHP file from a personal SHIP file of all continental 2015 US ZIP codes using population by ZIP—success. Run time for all was less than a couple minutes. Good luck!
Thank you for reporting. Actually, with the changes in Pysal library and both QGIS and Python versions the suggested installation of dependencies does not always work for all system versions.
The plugin is currently tested till QGIS LTR 3.16 with Pysal 2. The "crude" installation you suggest is for sure effective until other concurrent versions of QGIS/Pysal are not installed (in my experience)... but happy to see that in your case it worked!
Are you familiar with the general problem such that QGIS is unable to find OSGeo4W Python modules? During my Russian roulette of website searching, I noticed some had PYTHONHOME and PYTHONPATH set to the QGIS Python library. Also I found other plugins giving similar errors, e.g., sklearn not found. It seems possibly older QGIS version (<=3.18) didnt have this problem. Any ideas for a solution?
Untill QGIS 3.16.4 version, the PIP from Osgeo4W was working correclty. There was a change in Python version (3.9) on newer Windows QGIS and likely also paths changes. Regarding PySAL 2.0, this version implements some methods that is deprecated on Py 3.9 thus producing further errors. We should open some issues on QGIS official repo!
Traceback (most recent call last): File "C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python\qgis\utils.py", line 335, in startPlugin plugins[packageName] = package.classFactory(iface) File "C:/Users/kalma/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis__init__.py", line 34, in classFactory from .hotspot_analysis import HotspotAnalysis File "C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/Users/kalma/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 39, in from pysal.explore.esda.getisord import * File "C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'pysal.explore'
After installing pysal, commenting out import pysal.spreg and the area where it is trying to import and the pysal.common.pandas section, I keep getting this error when I try and install.