zMoooooritz / stapy

An easy to use SensorThings API Client written in Python
MIT License
6 stars 2 forks source link

Stapy 0.3.0 not available on Python 3.10 #46

Closed BWibo closed 1 year ago

BWibo commented 1 year ago

I am trying to POST an Observation using this script. This has been working fine, but (I assume) since an update to Python 3.10 I'm getting an error.

Versions:

Python 3.10.6 

Thx in advance!

`python script.py "https://my.api.url.de/v1.1"`

script.py:
```python

import stapy as sta
from gpiozero import CPUTemperature
import datetime
import sys

if len(sys.argv) > 1:
  api_URL = sys.argv[1]
  # print("Using API URL: " + api_URL + "\n")
else:
  raise ValueError('No API URL passed to script!')

sta.set_api_url(api_URL)

datastream_id = 168

#phenomenonTime = datetime.datetime.utcnow()
phenomenonTime = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")

cpu = CPUTemperature()
result = cpu.temperature

obs = sta.Post.observation(
  phenomenon_time = phenomenonTime,
  result = result,
  datastream_id = datastream_id
)

print("Posted Observation %d: %s   %6.2f" % (obs, phenomenonTime, result))

Error msg:

Request was not successful (Incorrect request: Failed to parse TimeInterval 2022-10-10T00:00:00-2022-10-28T00:00:00)
Posted Observation -1: 2022-10-28T09:24:10.553088Z    42.35
BWibo commented 1 year ago

OK, wait. I'm sorry. For some reason im having stapy==0.2.4 installed.

BWibo commented 1 year ago

The problem seems to be, that 0.3.0 is not found. However, I can see it here: https://pypi.org/project/stapy/

Any idea how to resolve this:

$ python -V
Python 3.10.6

$ pip -V
pip 22.3 from /home/USER/.local/lib/python3.10/site-packages/pip (python 3.10)

$ pip pip install stapy==0.3.0
ERROR: Ignored the following versions that require a different python version: 0.2.5 Requires-Python >=3.6,<3.10; 0.2.6 Requires-Python >=3.7,<=3.10; 0.2.7 Requires-Python >=3.7,<=3.10; 0.2.8 Requires-Python >=3.7,<=3.10; 0.3.0 Requires-Python >=3.7,<=3.10
ERROR: Could not find a version that satisfies the requirement stapy==0.3.0 (from versions: 0.1.2, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4)
ERROR: No matching distribution found for stapy==0.3.0
zMoooooritz commented 1 year ago

Thank you for your feedback, indeed this was a wrong configuration in my setup.py which enforces python versions <=3.10.0. I have removed the upper bound and will revisit as soon as any new python version breaks stapy.

You should now be able to install the newest version via pip install stapy==0.3.1. Attention: If you install any packages via pip without a version specifier and any previous version cached, pip will fallback on this version. As long as the requirements are met which was the case for version 0.2.4

BWibo commented 1 year ago

Many thanks for the quick fix. I can confirm it is working now on Python 3.10.6.