{"id":7596,"library":"pyowm","title":"PyOWM: OpenWeatherMap API Wrapper","description":"PyOWM is a Python wrapper library for the OpenWeatherMap web APIs, providing easy access to current weather conditions, forecasts, and historical weather data for various locations worldwide. It is currently at version 3.5.0 and actively maintained, with updates typically released to support new OpenWeatherMap API versions, features, and Python compatibility requirements.","status":"active","version":"3.5.0","language":"en","source_language":"en","source_url":"https://github.com/csparpa/pyowm","tags":["weather","openweathermap","api-wrapper","forecast","climate","geocoding","air-pollution"],"install":[{"cmd":"pip install pyowm","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for making HTTP requests to the OpenWeatherMap API. Implicit in API wrappers.","package":"requests"},{"reason":"Dependency for handling GeoJSON geometry objects. Specific version constraint (>=3,<4) since PyOWM 3.4.0.","package":"geojson","optional":false}],"imports":[{"symbol":"OWM","correct":"from pyowm import OWM"},{"note":"OWM25 and old manager access methods are deprecated in v3.x; use OWM and .weather_manager().","wrong":"owm = OWM25(API_KEY)\nmgr = owm.get_weather_manager()","symbol":"weather_manager","correct":"from pyowm.utils import config, timestamps\nowm = OWM(API_KEY)\nmgr = owm.weather_manager()"}],"quickstart":{"code":"import os\nfrom pyowm import OWM\n\nAPI_KEY = os.environ.get('OWM_API_KEY', 'your-api-key-here')\n\nif not API_KEY or API_KEY == 'your-api-key-here':\n    print(\"WARNING: OWM_API_KEY environment variable not set or is placeholder.\")\n    print(\"Please get a key from openweathermap.org and set it.\")\n    exit()\n\nowm = OWM(API_KEY)\nmgr = owm.weather_manager()\n\ntry:\n    # Search for current weather in a specific city\n    observation = mgr.weather_at_place('London,GB')\n    weather = observation.weather\n\n    print(f\"Current weather in London: {weather.status}, Temperature: {weather.temperature('celsius')['temp']}°C\")\n\n    # Get a One Call API daily forecast (requires One Call API 3.0 compatible key)\n    # For free keys, use 'One Call by Call' subscription, first 1000 calls/day are free.\n    one_call_forecaster = mgr.one_call(lat=51.5074, lon=-0.1278)\n    daily_forecast = one_call_forecaster.forecast_daily\n    if daily_forecast:\n        today = daily_forecast[0]\n        print(f\"Today's forecast: {today.status}, Max Temp: {today.temperature('celsius')['max_temp']}°C\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"Initialize PyOWM with your OpenWeatherMap API key (preferably from an environment variable). Then, use the `weather_manager` to fetch current weather conditions for a city or get a daily forecast using the One Call API 3.0. A free API key supports basic calls and the first 1000 calls/day for One Call by Call API."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. The library currently supports Python 3.9+.","message":"PyOWM v3.5.0 dropped support for Python 3.8. Python 3.8 reached end-of-life status. Attempting to use PyOWM 3.5.0+ with Python 3.8 will result in incompatibility.","severity":"breaking","affected_versions":">=3.5.0"},{"fix":"Ensure your OpenWeatherMap API key is compatible with One Call API 3.0. Update your code to use `one_call()` methods, especially for forecasts and historical data, as legacy `forecast_at_place()` may no longer work with newer free API keys.","message":"PyOWM v3.4.0 transitioned to OpenWeatherMap's One Call API 3.0, deprecating One Call API 2.5. OpenWeatherMap officially closed access to API 2.5 in June 2024. Older API keys or code relying on API 2.5 endpoints might fail.","severity":"breaking","affected_versions":">=3.4.0"},{"fix":"Refer to the PyOWM v3 migration guide in the official documentation. You will likely need to rewrite parts of your code, especially related to OWM object instantiation and manager calls (e.g., `OWM25` -> `OWM`, `get_weather_manager()` -> `weather_manager()`).","message":"PyOWM 3.0.0 was a major release that introduced significant backwards-incompatible changes from PyOWM 2.x, including a complete refactor of the high-level API functions and object model. This version also explicitly dropped Python 2.x support.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always use the `one_call()` method for comprehensive weather data (current, forecast, history) as it is the officially supported and future-proof approach for most use cases with current API keys. Check the OpenWeatherMap API documentation for endpoint compatibility with your subscription type.","message":"Newer free OpenWeatherMap API keys might return 'UnauthorizedError' or fail when attempting to access legacy API endpoints (e.g., `weather_at_coords` or `forecast_at_place` directly) that are not part of the One Call API 3.0, even if the key is valid.","severity":"gotcha","affected_versions":"All versions with new OWM API keys"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update your code to use the PyOWM v3 API. Replace `from pyowm.owm25 import OWM25` with `from pyowm import OWM` and adapt object instantiation and method calls (e.g., `owm = OWM(API_KEY)` and `mgr = owm.weather_manager()`).","cause":"You are attempting to use code written for PyOWM v2 with a PyOWM v3 library installation. The `OWM25` class and its methods (`get_weather_manager`, etc.) were removed in PyOWM v3.","error":"AttributeError: 'OWM25' object has no attribute 'xxx'"},{"fix":"Double-check your API key for typos. If using a new free key, ensure you are calling the `one_call()` methods. Verify your OpenWeatherMap account for API key status and subscription details. Allow some time (up to a few hours) for new API keys to become active.","cause":"The OpenWeatherMap API key provided is either incorrect, expired, or you are attempting to access an API endpoint not permitted by your subscription level or that is deprecated for your key type (e.g., using a new free key with legacy API 2.5 endpoints).","error":"UnauthorizedError: Invalid API Key provided."},{"fix":"Install the `geojson` package: `pip install geojson`. If you previously installed PyOWM, run `pip install --upgrade pyowm` to ensure all dependencies are correctly pulled in.","cause":"The `geojson` dependency, required by PyOWM 3.4.0 and later, is missing from your environment. This can happen if pip's dependency resolution fails or if installing from source without dependencies.","error":"ModuleNotFoundError: No module named 'geojson'"},{"fix":"Add error handling to check for the existence of keys before accessing them. For temperature, sometimes min/max/day/night temps might be available instead of a generic 'temp' depending on the API call (e.g., forecast vs current weather). Check the `weather.temperature()` output structure. For example, `print(weather.temperature('celsius'))` to see available keys.","cause":"This usually indicates that the weather data returned from the OpenWeatherMap API did not contain the expected 'temp' key within the temperature data. This can happen for certain locations or when the API response structure changes slightly.","error":"KeyError: 'temp' (or similar on weather.temperature('celsius')['temp'])"}]}