When trying to
import looker_sdk
in my code, I get a lot of error messages, and can't use the API anymore... I was able to use this 3 weeks ago, and haven't change my code at all. I went on 2 weeks vacation and it didn't work anymore.
Here's the traceback:
Traceback (most recent call last):
File "C:\Users\Humilton\Desktop\Main\Tests\Looker_Download_Look_Receive_Dates.py", line 1, in <module>
import looker_sdk
File "C:\Users\Humilton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\looker_sdk\__init__.py", line 32, in <module>
from looker_sdk.sdk.api31 import methods, methods as methods31 # noqa:F401
File "C:\Users\Humilton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\looker_sdk\sdk\api31\methods.py", line 32, in <module>
from . import models as mdls
File "C:\Users\Humilton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\looker_sdk\sdk\api31\models.py", line 11935, in <module>
sr.converter31.register_structure_hook(
File "C:\Users\Humilton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cattr\converters.py", line 186, in register_structure_hook
self._structure_func.register_cls_list([(cl, func)])
File "C:\Users\Humilton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cattr\multistrategy_dispatch.py", line 45, in register_cls_list
self._single_dispatch.register(cls, handler)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\functools.py", line 856, in register
raise TypeError(
TypeError: Invalid first argument to `register()`. ForwardRef('AccessToken') is not a class.
[Finished in 1.4s]
It's a work laptop. I've reinstalled Python (Python 3.10.2). I've reinstalled the Looker SDK (using pip).
I'm trying to use the Looker SDK, so I can download data from the Looker website at work. The import statement is the only code I'm executing. Anyone who knows what causes the error?
@raphael was correct. It seems like a bug introduced with Python 3.10. It seems like the work computer had installed a new Python version automatically.
I uninstalled Python (all versions) and then installed Python 3.8 (Btw: Python 3.9 didn't work for me).
Then I reinstalled Looker-sdk via pip, and it works.