Error using Pirate Weather to get current temperature - bug or cockpit error? #398
Closed
three-jeeps
started this conversation in
General
Replies: 2 comments
-
The issue with the script is that when you go to print out the temperature you're missing the () after currently. So it should be import pirateweather
def main():
api_key = "MyApiKey" #my api key filled in later
latitude = 37.7749 # Example: San Francisco
longitude = -122.4194
forecast = pirateweather.load_forecast(api_key, latitude, longitude)
print(forecast.currently())
print(f"Temperature: {forecast.currently().temperature} F")
if __name__ == '__main__':
main() You're using the Python library to query the API correct? If you have any questions with using the library feel free to ask there if you're running into issues. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you!
Appreciate the pointer to the pirateweather python library.
…On Thu, Jan 9, 2025 at 12:25 PM Kev ***@***.***> wrote:
The issue with the script is that when you go to print out the temperature
you're missing the () after currently. So it should be
forecast.currently().temperature instead of what you have currently. I've
added the corrected script below (the API uses US units so I changed the C
to F):
import pirateweatherdef main():api_key = "MyApiKey" #my api key filled in laterlatitude = 37.7749 # Example: San Franciscolongitude = -122.4194forecast = pirateweather.load_forecast(api_key, latitude, longitude)print(forecast.currently())print(f"Temperature: {forecast.currently().temperature} F")if __name__ == '__main__':main()
You're using the Python library
<https://github.com/cloneofghosts/python-pirate-weather> to query the API
correct? If you have any questions with using the library feel free to ask
there if you're running into issues.
—
Reply to this email directly, view it on GitHub
<#398 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVZNW7WKJ743TQ325FVGLL2J2WGXAVCNFSM6AAAAABU4QZLSCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNZYHEZDQNQ>
.
You are receiving this because you authored the thread.Message ID:
<Pirate-Weather/pirateweather/repo-discussions/398/comments/11789286@
github.com>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am exploring Pirate weather to get both current weather data and future forecasts, I am using this python script to do a single thing - get current temperature at specified coordinates and I get an error: AttributeError: 'function' object has no attribute 'temperature'
If I comment out 'print(f"Temperature: {forecast.currently.temperature}°C") the forecast.currently returns expected data - <PirateWeatherDataPoint instance: Clear at 2025-01-06 12:07:00>
Why is .temperature not valid? how to fix? Not sure this is the right place for this question but I can't find any other location.
Here is the script- thanks for any help
Beta Was this translation helpful? Give feedback.
All reactions