Closed smuurling closed 3 years ago
Actually, your comment below worked for me! https://github.com/danioxoli/HotSpotAnalysis_Plugin/issues/64#issuecomment-907174436
I was exactly pointing you at that.
Thank you for anticipating me!
Hi Daniele, Thank you so much for your efforts in maintaining HA plugin.
I use QGIS 3.22.4 with PySAL 2.0 and I run the last version of Hotspot Analysis, however, I keep getting an error identical to that of this topic's opener ('array.array' object has no attribute 'fromstring').
AttributeError: 'array.array' object has no attribute 'fromstring' Traceback (most recent call last): File "C:\Users/humbo/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\HotSpotAnalysis_Plugin-qgis3pysal2\hotspot_analysis.py", line 612, in run w = Queen.from_shapefile(layerName.split("|")[0]) File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 236, in from_shapefile w = cls(FileIO(filepath), ids=ids, *kwargs) File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 182, in init neighbors, ids = _build(polygons, ids=ids, File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 385, in _build neighbor_data = ContiguityWeightsLists(polygons, wttype=wttype).w File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights_contW_lists.py", line 53, in init self.collection = list(collection) File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 254, in next r = self.read() File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 315, in read row = self._read() File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\iohandlers\pyShpIO.py", line 140, in _read rec = self.dataObj.get_shape(self.pos) File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 362, in get_shape return self.shape.unpack(bufferIO(self.fileObj.read(byts))) File "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 636, in unpack _unpackDict2(record, contentStruct, dat) File "C:\Users\humbo\AppData\Roaming\Python\Python39\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'
Elsewhere, (https://github.com/danioxoli/HotSpotAnalysis_Plugin/issues/64#issuecomment-907174436) you were suggesting to manually substitute fromstring method with frombytes.
As I'm very basic with python, can I ask you how to correctly do this manual substitution? Thank you!
It is not clear why the error persists with PySAL > 2 but you can try the same correction by opening from your folder browser the path "C:\Users\humbo\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util". Once in the folder, look for "shapefile.py" file and open it with a text editor to make the suggested correction. Just remember to save the change at the end.
Thank you! Now it works!
Thanks so much for this plugin Daniele, I really hope that I will get it to work. I am working with QGIS 3.20.2, have pysal 2.0.0 installed, and was able to obtain the plugin through the Plugin tab in QGIS. Still, I get this error. Do you have any ideas on how I can get it to work? (Like install python 3.7 or something?)
Traceback (most recent call last): File "C:\Users/Sawna/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\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 236, in from_shapefile w = cls(FileIO(filepath), ids=ids, *kwargs) File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 182, in init neighbors, ids = _build(polygons, ids=ids, File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights\contiguity.py", line 385, in _build neighbor_data = ContiguityWeightsLists(polygons, wttype=wttype).w File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\weights_contW_lists.py", line 53, in init self.collection = list(collection) File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 254, in next r = self.read() File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\fileio.py", line 315, in read row = self._read() File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\iohandlers\pyShpIO.py", line 140, in _read rec = self.dataObj.get_shape(self.pos) File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 362, in get_shape return self.shape.unpack(bufferIO(self.fileObj.read(byts))) File "C:\Users\Sawna\AppData\Roaming\Python\Python39\site-packages\pysal\lib\io\util\shapefile.py", line 636, in unpack _unpackDict2(record, contentStruct, dat) File "C:\Users\Sawna\AppData\Roaming\Python\Python39\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'