Module 'numpy' has no attribute 'asscalar'


I am trying to call a server function after loading an ascii file (size=1038KB) with the file loader button on the client side. All this code was working fine a few hours ago, but now it fails when making the call to the function with this error .

AnvilWrappedError: module ‘numpy’ has no attribute ‘asscalar’
at /home/anvil/.env/lib/python3.10/site-packages/numpy/, line 311
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil/, line 983
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil/, line 934
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil/, line 940
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil/, line 934
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil/, line 999
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil/, line 133
called from /home/anvil/.downlink-sources/downlink-2022-09-02-10-37-54/anvil_downlink_worker/, line 49
called from Mainwells, line 78

I’ve tried loading different files and sizes without success. When I search for this error on google it states that this attribute ‘asscalar’ is deprecated on versions of numpy after versions 1.16. Does this mean that the server is now running a newer version of numpy and if so how do I get around this issue.

Code snippet that is casing there at line 78 is below.
Code Sample:

def create_lasWell_fileloader_change(self, file, **event_args):
    welldict ='readlasfileheader',file)

Thanks for any help on this issue.


Clone link:
share a copy of your app

Hi @pboothby and welcome to the community.

It looks like the numpy.asscalar() function was deprecated in v1.16. I am not sure if Anvil has upgraded its numpy version but that might be the reason it no longer works.

From the numpy docs

Deprecated since version 1.16: Deprecated, use numpy.ndarray.item() instead.

Link to numpy.ndarray.item

Thanks @rickhurlbatt. Since posting I have done quite a bit more debugging and discovered that when the code gets to the ‘return’ line at the end of the sever function its throwing this error so not sure why its throwing a ‘numpy’ error, when there is no reference to numpy in my code. Trying to return a dictionary object which seems to be the issue.

1 Like

Thanks for reporting. Moved to bug reports.