danioxoli / HotSpotAnalysis_Plugin

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

ImportError: Something is wrong with the numpy installation QGIS 3.4.5 #26

Closed edurojasr closed 4 years ago

edurojasr commented 5 years ago

Hi @danioxoli

I tried to use the plugin, but there is a problem with the installation. Tried in QGIS 3.4.5 (probably it has not been tested in this QGIS release).

I have install the plugin following this instructions:

 $ py3_env
 $ python -m pip install --upgrade pip
 $ python -m pip install -I pysal==1.14.3

The issue have 2 parts, so I'm going to explain both:

Part 1: Cant use the plugin so its give this error

Unable to load 'HotspotAnalysis' plug-in due to an error calling your classFactory () method

ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version. Traceback (most recent call last):

File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 335, in startPlugin plugins[packageName] = package.classFactory(iface) File "C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python/plugins\HotspotAnalysis__init.py", line 34, in classFactory from .hotspot_analysis import HotspotAnalysis File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 38, in import pysal File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\pysal__init.py", line 40, in import pysal.cg File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\pysal\cg__init__.py", line 4, in from .shapes import * File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\pysal\cg\shapes.py", line 12, in from .sphere import arcdist File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\pysal\cg\sphere.py", line 15, in import numpy File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy\init__.py", line 142, in from . import core File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy\core\init__.py", line 91, in raise ImportError(msg.format(path)) ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

Versión de Python: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] Versión de QGIS: 3.4.5-Madeira Madeira, 89ee6f6e23

Ruta de Python: C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python/plugins C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins C:\Program Files\QGIS 3.4\bin\python37.zip C:\PROGRA~1\QGIS 3.4\apps\Python37\DLLs C:\PROGRA~1\QGIS 3.4\apps\Python37\lib C:\Program Files\QGIS 3.4\bin C:\Users\eduar\AppData\Roaming\Python\Python37\site-packages C:\PROGRA~1\QGIS 3.4\apps\Python37 C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\win32 C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\win32\lib C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\Pythonwin C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python

Part 2: The processing toolbox it broke so cant use any processing module, have to reinstall QGIS

Unable to load the 'processing' plug-in

ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version. Traceback (most recent call last):

File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 309, in loadPlugin import(packageName) File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins\processing__init.py", line 29, in from processing.tools.general import * # NOQA File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 39, in from processing.core.Processing import Processing File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 58, in from processing.algs.qgis.QgisAlgorithmProvider import QgisAlgorithmProvider # NOQA File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins\processing\algs\qgis\QgisAlgorithmProvider.py", line 81, in from .HypsometricCurves import HypsometricCurves File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins\processing\algs\qgis\HypsometricCurves.py", line 29, in import numpy File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy__init__.py", line 142, in from . import core File "C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy\core\init__.py", line 91, in raise ImportError(msg.format(path)) ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

Versión de Python: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] Versión de QGIS: 3.4.5-Madeira Madeira, 89ee6f6e23

Ruta de Python: C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python/plugins C:/PROGRA~1/QGIS 3.4/apps/qgis-ltr/./python/plugins C:\Program Files\QGIS 3.4\bin\python37.zip C:\PROGRA~1\QGIS 3.4\apps\Python37\DLLs C:\PROGRA~1\QGIS 3.4\apps\Python37\lib C:\Program Files\QGIS 3.4\bin C:\Users\eduar\AppData\Roaming\Python\Python37\site-packages C:\PROGRA~1\QGIS 3.4\apps\Python37 C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\win32 C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\win32\lib C:\PROGRA~1\QGIS 3.4\apps\Python37\lib\site-packages\Pythonwin C:/Users/eduar/AppData/Roaming/QGIS/QGIS3\profiles\cursos/python

As you can see the problem seems to be from the installation of numpy an "older version of numpy" I suppose it must be for the installation of PySAL version <= 1.14.3 because when installed with:

$ python -m pip install pysal

which installs the version Pysal 2.0 processing does not break, but the plugin does not work.

I hope this feedback is helpful to use the plugin in the new LTR version of QGIS, I am here to help as much as possible.

danioxoli commented 5 years ago

Dear Eduardo,

Thank you for your feedback.

I share with you my current set up for QGIS3.4 and Py3.7 on my Windows VM:

C:\Windows\System32>pip3 list
Package          Version
---------------- -----------
certifi          2018.8.24
chardet          3.0.4
coverage         4.5.1
cycler           0.10.0
decorator        4.3.0
ExifRead         2.1.2
future           0.16.0
GDAL             2.3.2
httplib2         0.11.3
idna             2.7
ipython-genutils 0.2.0
Jinja2           2.10
jsonschema       2.6.0
jupyter-core     4.4.0
kiwisolver       1.0.1
MarkupSafe       1.0
matplotlib       3.0.0
mock             2.0.0
nbformat         4.4.0
networkx         2.2
nose2            0.8.0
numpy            1.15.3
OWSLib           0.17.0
pbr              4.3.0
pip              18.1
plotly           3.3.0
psycopg2         2.7.5
Pygments         2.2.0
pyodbc           4.0.24
pyparsing        2.2.2
pypiwin32        223
pyproj           1.9.5.1
PyQt5            5.11.3
PySAL            1.13.0
python-dateutil  2.7.3
pytz             2018.5
pywin32          224
PyYAML           3.13
requests         2.19.1
retrying         1.3.3
scipy            1.1.0
setuptools       40.4.3
Shapely          1.6.4.post2
simplejson       3.16.0
sip              4.19.13
six              1.11.0
traitlets        4.3.2
urllib3          1.23
xlrd             1.1.0
xlwt             1.3.0 

With this everything works correctly.

I've never faced the problems with NumPy version also on other machines by using the workaround it is suggested in the README. However, I will try to dig in the issue to understand possible causes.

Actually, the plugin needs to be updated by changing the PySAL import and API calls which syntax has been substantially changed by the PySAL dev between version <=1.14 and version >= 2.0. This will be the definitive solution to avoid version downgrades that may cause some mess. I hope to find the time to do this critical update as well as to explore the possibility of including the PySAL code directly into the plugin.

Best,

Daniele

edurojasr commented 5 years ago

Hi @danioxoli

This is my current set up for QGIS3.4.6 and Py3.7 on my Windows 10. Its the default QGIS 3.4.6 standalone installation

C:\Windows\System32>pip3 list
Package           Version
----------------- -----------
astroid           2.0.4
certifi           2018.8.24
chardet           3.0.4
colorama          0.4.0
coverage          4.5.1
cycler            0.10.0
decorator         4.3.0
ExifRead          2.1.2
future            0.16.0
GDAL              2.4.1
httplib2          0.11.3
idna              2.7
ipython-genutils  0.2.0
isort             4.3.4
Jinja2            2.10
jsonschema        2.6.0
jupyter-core      4.4.0
kiwisolver        1.0.1
lazy-object-proxy 1.3.1
MarkupSafe        1.0
matplotlib        3.0.0
mccabe            0.6.1
mock              2.0.0
nbformat          4.4.0
networkx          2.2
nose2             0.8.0
**numpy             1.15.4**
OWSLib            0.17.0
pbr               4.3.0
Pillow            5.3.0
pip               18.1
plotly            3.3.0
psycopg2          2.7.5
Pygments          2.2.0
pylint            2.1.1
pyodbc            4.0.24
pyparsing         2.2.2
pypiwin32         223
pyproj            1.9.6
PyQt5             5.11.3
python-dateutil   2.7.5
pytz              2018.7
pywin32           224
PyYAML            3.13
requests          2.19.1
retrying          1.3.3
scipy             1.1.0
setuptools        40.4.3
Shapely           1.6.4.post2
simplejson        3.16.0
sip               4.19.14
six               1.11.0
traitlets         4.3.2
urllib3           1.23
wrapt             1.10.11
xlrd              1.1.0
xlwt              1.3.0

As you can see the numpy package it's more recently than your, maybe that's where the problem with numpy and PySAL 1.14.3 comes from