1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] ModuleNotFoundError: No module named 'urllib3.packages.six.moves' in a simple weather...

Discussão em 'Python' iniciado por Stack, Outubro 5, 2024 às 21:32.

  1. Stack

    Stack Membro Participativo

    When I run the code, I get the error "ModuleNotFoundError: No module named 'urllib3.packages.six.moves", this is despite the fact that I have uninstalled and reinstalled six, requests and urllib3 many times.

    Code:

    import requests
    import json


    def get_weather(city, api_key):
    base_url = "http://api.openweathermap.org/data/2.5/weather?"


    complete_url = base_url + "q=" + city + "&appid=" + api_key + "&units=metric"

    response = requests.get(complete_url)
    data = response.json()

    if data["cod"] != "404":
    main = data["main"]
    wind = data["wind"]
    weather = data["weather"][0]
    temperature = main["temp"]
    humidity = main["humidity"]
    weather_description = weather["description"]
    wind_speed = wind["speed"]

    print(f"City: {city}")
    print(f"Temperature: {temperature}°C")
    print(f"Humidity: {humidity}%")
    print(f"Weather: {weather_description.capitalize()}")
    print(f"Wind Speed: {wind_speed} m/s")

    else:
    print(f"City {city} not found. Please enter a valid city name.")


    if __name__ == "__main__":
    api_key = "5a249ac961fe0222f884ded14818c13e"
    city = input("Enter city name: ")
    get_weather(city, api_key)


    I tried to run the program, a text output was meant to appear which then asked for the users city for them to then input it and weather info to appear. I have tried reinstalling six, requests and urllib3, deleted a 0kb version of python in the microsoft directory and done "sfc /scannow".

    Continue reading...

Compartilhe esta Página