Skip to main content

I am trying to run a code to fetch timeseries based on some tags available in a project. While I execute the same code using jupyter notebooks in CDF online-notebook feature, the code runs fine. 

When I am trying to run the same code script in local after setting up connectivity using interactive-login and then when I run the timeseries retrieve code, I am getting an error. Please help.

Code:

from datetime import datetime, timezone
utc = timezone.utc


pi= client.time_series.data.retrieve_dataframe(external_id=d'pi:2FC1898.DACA.PV','pi:2TC1066.DACA.PV','pi:LAB_133-X013_APIGRAVOB','pi:2FC1898.PIDA.OP'],
start=datetime(2023, 1, 1, tzinfo=utc),
end=datetime(2023, 5, 1, tzinfo=utc),
aggregates=s"average"],
granularity="1d")

 

 

Error- Traceback:

---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)Cell In  9], line 5      1 from datetime import datetime, timezone      2 utc = timezone.utc----> 5 pi= client.time_series.data.retrieve_dataframe(external_id=_'pi:2FC1898.DACA.PV','pi:2TC1066.DACA.PV','pi:LAB_133-X013_APIGRAVOB','pi:2FC1898.PIDA.OP'],      6                     start=datetime(2023, 1, 1, tzinfo=utc),      7                     end=datetime(2023, 5, 1, tzinfo=utc),      8                     aggregates=t"average"],      9                     granularity="1d")AttributeError: 'TimeSeriesAPI' object has no attribute 'data'

 

 

Hey @eashwar11 , please update the version of SDK installed locally. 


Hi @eashwar11 ! It seems you are running with an older / outdated version of the Cognite Python SDK! Try upgrading and the problem should go away! 😊 

Edit: @roman.chesnokov beat me to it


Thanks @roman.chesnokov @Håkon V. Treider 

It worked. I ran the upgrade command 

pip install --upgrade cognite-sdk

in a project specific folder and when launched the notebook from that folder, it worked.

Should I add this SDK in my PATH variable so that it runs for any notebook in any folder?


@eashwar11 it depends on your setup. We usually use poetry for our local projects, so if I need to update something, I update the version in the toml file.


Reply