Open larkinsaj opened 3 years ago
Hello,
I discovered that fromstring method is deprecated on Python 3.9. Currently, QGIS should use Python 3.7 (at least on Windows) but I see it is not your case.
The util/shapefile.py is a PySAL function is not something that is developed by us. You may try to upgrade PySAL to version 2.2.0 or 2.4.0 and see if this has been fixed. Unfortunately, I did a test on Windows but versions higher than 2.0.0 gives some problems with dependencies.
I will investigate better the issue and, in case, let you know here if a robust solution emerges.
Best,
Daniele
Hi Daniele, Thanks for your nice plugin. I had the same issue. ——“AttributeError: 'array.array' object has no attribute 'fromstring'” Running win10 19043.1165 & thinkpad e15 & QGIS 3.16.
I am also sure the issue from pysal.
Hello,
is this happening with PySAL > 2.0 or you are still using the plugin version based on PySAL 1.14? The error is connected to the Python versions and the manual way of correcting it would be to replace fromstring
to frombytes
method in the pysal file pysal/lib/io/util/shapefile.py
. However, with the latest version of the plugin based on PySAL == 2.0 (published few days ago), this should not happen anymore. Just need to update the Pysal version installed in QGIS and re-install the plugin.
Hope this will be useful.
Best
Just installed the plugin with PySal 2.0.0 for the first time today and I am getting a python Error whenever I open the plugin
2021-09-09T11:26:41 WARNING Traceback (most recent call last): File "C:/Users/AlexandreChéné/AppData/Roaming/QGIS/QGIS3\profiles\ACHENE/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 552, in run self.load_comboBox() File "C:/Users/AlexandreChéné/AppData/Roaming/QGIS/QGIS3\profiles\ACHENE/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 473, in load_comboBox thresh = pysal.lib.weights.user.min_threshold_dist_from_shapefile(path) File "C:\OSGEO4~1\apps\Python37\lib\site-packages\pysal\lib\weights\user.py", line 86, in min_threshold_dist_from_shapefile points = get_points_array_from_shapefile(shapefile) File "C:\OSGEO4~1\apps\Python37\lib\site-packages\pysal\lib\weights\util.py", line 1075, in get_points_array_from_shapefile data = get_points_array(f) File "C:\OSGEO4~1\apps\Python37\lib\site-packages\pysal\lib\weights\util.py", line 1026, in get_points_array data = np.vstack([np.array(shape.centroid) for shape in iterable]) File "", line 6, in vstack File "C:\OSGEO4~1\apps\Python37\lib\site-packages\numpy\core\shape_base.py", line 283, in vstack return _nx.concatenate(arrs, 0) File "", line 6, in concatenate ValueError: need at least one array to concatenate
Hello, I am having the same problem even after these changes. I am guessing it would be better to install a previous version of QGIS that uses 3.7Pyhton? But would still like to know if anyone still comes across this problem. Thank you
An error has occurred while executing Python code:
AttributeError: 'array.array' object has no attribute 'fromstring' Traceback (most recent call last): File "C:\Users/00111374/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotspotAnalysis\hotspot_analysis.py", line 612, in run w = Queen.from_shapefile(layerName.split("|")[0]) File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 238, in from_shapefile w = cls(FileIO(filepath), ids=ids, *kwargs) File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 183, in init neighbors, ids = _build(polygons, ids=ids, File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 388, in _build neighbor_data = ContiguityWeightsLists(polygons, wttype=wttype).w File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights_contW_lists.py", line 53, in init self.collection = list(collection) File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 254, in next r = self.read() File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 315, in read row = self._read() File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\iohandlers\pyShpIO.py", line 144, in _read rec = self.dataObj.get_shape(self.pos) File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 382, in get_shape return self.shape.unpack(io.BytesIO(self.fileObj.read(byts))) File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 687, in unpack _unpackDict2(record, contentStruct, dat) File "C:\Users\00111374\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 155, in _unpackDict2 result.frombytes(fileObj.read(result.itemsize n)) AttributeError: 'array.array' object has no attribute 'fromstring'
Hi Daniele,
Thanks for creating and maintaining this plugin. I was able to successfully install the plugin. Running macOS Big Sur 11.3 & QGIS 3.16. I ran into the Python error below when trying to run Gi* on a polygon layer. I repeated on the polygon test data that you supply and had the same issue. Any help would be much appreciated. Would love to use your plugin for my PhD rather than R or jumping between QGIS and GeoDa.
Cheers, Andrew
WARNING Traceback (most recent call last): File "/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/HotSpotAnalysis_Plugin-qgis3pysal2/hotspot_analysis.py", line 612, in run w = Queen.from_shapefile(layerName.split("|")[0]) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/weights/contiguity.py", line 236, in from_shapefile w = cls(FileIO(filepath), ids=ids, *kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/weights/contiguity.py", line 182, in init neighbors, ids = _build(polygons, ids=ids, File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/weights/contiguity.py", line 385, in _build neighbor_data = ContiguityWeightsLists(polygons, wttype=wttype).w File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/weights/_contW_lists.py", line 53, in init self.collection = list(collection) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/io/fileio.py", line 254, in next r = self.read() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/io/fileio.py", line 315, in read row = self._read() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/io/iohandlers/pyShpIO.py", line 140, in _read rec = self.dataObj.get_shape(self.pos) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/io/util/shapefile.py", line 362, in get_shape return self.shape.unpack(bufferIO(self.fileObj.read(byts))) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/io/util/shapefile.py", line 636, in unpack _unpackDict2(record, contentStruct, dat) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pysal/lib/io/util/shapefile.py", line 155, in _unpackDict2 result.fromstring(fileObj.read(result.itemsize n)) AttributeError: 'array.array' object has no attribute 'fromstring'