danioxoli / HotSpotAnalysis_Plugin

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

Issue with HotSpot Analysis Plugin - no module named shapes #15

Closed GitHubMLee closed 2 years ago

GitHubMLee commented 5 years ago

I have been trying unsuccessfully to get this plugin working on a Windows machine running QGIS 3.2.3 that was installed through OSGeo4W. I followed the instructions to upgrade pip and install pysal but I am receiving the following error in the QGIS Python log when I try to initiate the plugin:

Traceback (most recent call last): File "C:\OSGEO4~1\apps\Python36\lib\code.py", line 91, in runcode exec(code, self.locals) File "", line 1, in File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 674, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\OSGEO4~1\apps\Python36\lib\site-packages\pysal__init__.py", line 40, in import pysal.cg File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 674, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\OSGEO4~1\apps\Python36\lib\site-packages\pysal\cg__init__.py", line 4, in from shapes import * File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 674, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'shapes'

The same error happens when I run the command Install Pysal in the console.

Any help would be most appreciated! (PS I am a newbie with anything technical in Python)

danioxoli commented 5 years ago

Dear Matthew,

Thanks for reporting.

This is a known issue that sometimes shows up due to some machine setting. Here the discussion I found on the PySAL repo: https://github.com/pysal/pysal/issues/693 To more than one Windows user, the problem was fixed by repeating the installation of PySAL as follows:

py3_env
pip uninstall pysal 
pip install --no-cache-dir pysal

Let me know please if this will solve the problem!

Best,

Daniele

GitHubMLee commented 5 years ago

Thank you so much. The plugin is working now!

image

jyao28 commented 5 years ago

Hi Daniele, I could not make this plugin working on Windows. I am using QGIS 3.4.2 and have upgraded pip and install pysal following the instruction. I am receiving the following error when initiate the plugin:

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

AttributeError: module 'pysal' has no attribute 'common' Traceback (most recent call last): File "C:\OSGEO4~1\apps\Python37\lib\site-packages\pysal__init__.py", line 44, in import pandas File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'pandas'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 335, in startPlugin plugins[packageName] = package.classFactory(iface) File "C:/Users/jyao2/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis__init.py", line 34, in classFactory from .hotspot_analysis import HotspotAnalysis File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/Users/jyao2/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 38, in import pysal File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\OSGEO4~1\apps\Python37\lib\site-packages\pysal\init__.py", line 48, in pysal.common.pandas = None AttributeError: module 'pysal' has no attribute 'common'

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] QGIS version: 3.4.2-Madeira Madeira, 22034aa070

Could you please check?

danioxoli commented 5 years ago

It looks like PySAL requires Pandas library. I am not aware of that because of the declared dependencies are still only NumPy and SciPy. Never saw this error before.

Just for testing purposes, could you try:

py3_env
pip uninstall pysal 
pip install pandas
pip install --no-cache-dir pysal

(remember to run the OSGeo shell as administrator)

let me know if this help!

Daniele

jyao28 commented 5 years ago

Thanks Daniele for replying. Installed pandas following your instruction. Still not work with the same error message. Is this because the latest version (QGIS version: 3.4.2 and Python 3.7) is not supported yet? I will try to the older QGIS versions and see how things goes. Cheers John

danioxoli commented 5 years ago

Dear John,

Honestly, I tested the plugin on QGIS 3.2 only for Windows, Ubuntu, and MacOS. This version uses Python 3.6.

The missing functions in PySAL are showing up only with Py 3.7 that is the Python version of QGIS 3.4+ on Windows. Therefore, I concluded that this may be due to the Py 3.7 on Windows.

I suggest checking if this issue does not appear on older versions of QGIS (e.g. 3.2). Meanwhile, I will try to figure out and fix the problem for the latest release.

Thank you!

Daniele

zampatti commented 5 years ago

Dear Daniele, I tried to solve the problem but I still have it, or better I have something new... :(

2018-12-05T17:50:47 WARNING 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/Davide/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3__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/Davide/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3\hotspot_analysis.py", line 38, in import pysal 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal__init__.py", line 107, in import pysal.spreg 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\init.py", line 1, in from .ols 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) File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\ols.py", line 7, in from . import user_output as USER 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\user_output.py", line 9, in from . import diagnostics 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\diagnostics.py", line 12, in from .utils import spmultiply, sphstack, spmin, spmax 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\utils.py", line 10 author__ = "Luc Anselin luc.anselin@asu.edu, \ ^ SyntaxError: EOL while scanning string literal

could you help me to solve this?

Kind Regards, Davide

zampatti commented 5 years ago

Dear Daniele, it still not working :(

2018-12-05T18:29:22 WARNING 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/Davide/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3__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/Davide/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3\hotspot_analysis.py", line 38, in import pysal 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal__init__.py", line 95, in import pysal.spreg 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\init.py", line 1, in from .ols 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) File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\ols.py", line 7, in from . import user_output as USER 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\user_output.py", line 9, in from . import diagnostics 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\diagnostics.py", line 11, in from .utils import spmultiply, sphstack, spmin, spmax 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:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\pysal\spreg\utils.py", line 10 author__ = "Luc Anselin luc.anselin@asu.edu, \ ^ SyntaxError: EOL while scanning string literal

Kind regards,

Davide

danioxoli commented 5 years ago

Dear Davide,

I found a workaround that allowed me to run the plugin on QGIS 3.4 on Windows.

After installing PySAL following the instructions, open this file in a text editor as Admin:

"C:\Program Files\QGIS 3.4\apps\Python37\Lib\site-packages\pysal\ init .py"

comment line 95, like:

# import pysal.spreg

((I also trashed the subfolder: "C:\Program Files\QGIS 3.4\apps\Python37\Lib\site-packages\pysal\spreg“ to be sure it won’t be called. I think this is not necessary)

Save the changes and run QGIS. The problem should be solved!

schermata 2018-12-06 alle 16 26 33

It is a rough solution but better than nothing...

I have tested it on PySAL 1.13 (it should be the same on the 1.14).

Let me know if this works also for you!

Daniele

zampatti commented 5 years ago

Thanks it is a big improovement but i still have problems when i start the plugin: 2018-12-06T23:45:57 WARNING Traceback (most recent call last): File "C:/Users/Davide/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3\hotspot_analysis.py", line 551, in run self.load_comboBox() File "C:/Users/Davide/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3\hotspot_analysis.py", line 473, in load_comboBox self.dlg.lineEditThreshold.setText(str(int(thresh))) OverflowError: cannot convert float infinity to integer

Kind regards,

Davide

danioxoli commented 5 years ago

Dear Davide,

Could you move this into a new issue, please? Actually, what you are facing I belive is due to the input data rather than the Pysal installation itself. I will reply there

Thank you!

yanchen00 commented 3 years ago

Hi Daniele, I have problem on installing pysal on OSGeo4W. I have tried several times but it turn out to be this eventually. What is the cause of the problem and how do I solve it? by the way I'm using 3.8.1

image

danioxoli commented 3 years ago

Hello,

I am not sure about the error as rasterio should not be a dependency of the pysal 1.14 version that you need for running the plugin. I believe the issue may be connected to the version of QGIS. Please, try a clean installation on the Long Term Release version of QGIS (3.10) which is the tested version for the last test of the plugin I have considered.

You may be also interested in the dev version of the plugin for pysal 2.0 (installation procedure here )

Best,

Daniele

anand635 commented 3 years ago

ModuleNotFoundError: No module named 'pysal.esda' Traceback (most recent call last): File "C:/PROGRA~1/QGIS3~1.16/apps/qgis-ltr/./python\qgis\utils.py", line 334, in _startPlugin plugins[packageName] = package.classFactory(iface) File "C:/Users/anand/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.16/apps/qgis-ltr/./python\qgis\utils.py", line 792, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/Users/anand/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 39, in from pysal.esda.getisord import * File "C:/PROGRA~1/QGIS3~1.16/apps/qgis-ltr/./python\qgis\utils.py", line 792, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'pysal.esda'

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] QGIS version: 3.16.5-Hannover Hannover, 58ba7c1ed6

danioxoli commented 3 years ago

please, try to use the latest plugin version that you can find here: https://github.com/danioxoli/HotSpotAnalysis_Plugin/tree/qgis3pysal2

This version requires PySAL 2 and it has been fixed for the latest LTR. I will move it to the Master branch asap as well as on the QGIS plugin repo

Best,