smartsheet-platform / smartsheet-python-sdk

Library that uses Python to connect to Smartsheet services (using API 2.0).
Apache License 2.0
136 stars 81 forks source link

"ImportError! Could not load api or model class shape" using 3.7.12 and 3.8.12 #171

Open mnissman opened 2 years ago

mnissman commented 2 years ago

I am not able to get smartsheet-python-sdk latest version (2.105.1) to work with python version 3.7.12 or 3.8.12. The following intro code give me the error "ImportError! Could not load api or model class shape". access_token created through my smartsheet account and defined in the environment.

import smartsheet
smartsheet_client = smartsheet.Smartsheet(access_token)

I see the package lists support for 3.6. My Mac running Big Sur on Intel chip doesn't support 3.6. I would be very happy to be able to use the package. Is there any intention to add support for newer python versions, especially since 3.6 is reaching EOL at the end of 2021?

Thanks.

andrewtmendoza commented 2 years ago

Same issue, any luck?

RCoff commented 2 years ago

@mnissman Can you provide the exception traceback for this?

mnissman commented 2 years ago

@RCoff, @andrewtmendoza Thanks for your interest. The error seems to be IDE related (I'm using pyCharm) and does not occur in Python shell.

In the IDE, upon initialization of the smartsheet client in my originally posted code, I get the error below printed. Any subsequent calls through the client have the same printed error. However, the code is still running and returning corrrect results as far as I can tell.

smartsheet_client = smartsheet.Smartsheet(access_token=access_token)
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape

I tried suppressing the error but it does nothing. I guess it is more of an annoyance now that I figured out the code is actually returning the right results and is only IDE related.

from contextlib import suppress
for sheet in sheets:
    with suppress(ImportError):
        print(sheet.id)
7711112721393540
8321868345173892
1053171993864068
2081613187180420
1003518950696836
5556771621234564
5459312907708292
6070068531488644
3867921760970628
6585212814550916
5507118578067332
8085930759219076
352456979834756
3207513094023044
3818268717803396
8371521388341124
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
ImportError! Could not load api or model class shape
RCoff commented 2 years ago

I see now! I have also ran into this issue frequently when using the PyCharm debugger.

According to this SO article, the issue is related to ipython: https://stackoverflow.com/questions/57118472/python-for-smartsheet-getting-ipython-canary-method-should-not-exist

To mitigate this, I usually disable logging for the Smartsheet library.

import logging
logging.getLogger('smartsheet').setLevel(logging.CRITICAL)