Есть телеграмм бот, в нём код для погоды.
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
import os, json, string
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.state import State, StatesGroup
from aiogram.dispatcher.filters import Text
import sqlite3 as sq
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton, InputTextMessageContent, InlineQueryResultArticle
from pprint import pprint
import datetime
import requests
@dp.message_handler(commands=['Weather'])
async def start_wether(message: types.Message):
await bot.send_message(message.from_user.id, 'Введите названия города.')
@dp.message_handler()
async def get_wether(message: types.Message):
code_to_smile = {
'Claer': 'Ясно \U00002600',
"Clouds": "Облачно \U00002601",
"Rain": "Дождь \U00002614",
"Drizzle": "Дождь \U00002614",
"Thunderstorm": "Гроза \U000026A1",
"Snow": "Снег \U0001F328",
"Mist": "Туман \U0001F32B"
}
try:
open_weather_token = '****************************'
data = requests.get(f'https://api.openweathermap.org/data/2.5/weather?q={message.text}&appid={open_weather_token}&units=metric')\
.json()
city = data['name']
temp = data['main']['temp']
weather_description = data['weather'][0]['main']
if weather_description in code_to_smile:
wd = code_to_smile[weather_description]
else:
wd = '\U0001F600'
humidity = data['main']['humidity']
pressure = data['main']['pressure']
wind_speed = data['wind']['speed']
sunsire_timestamp = datetime.datetime.fromtimestamp(data["sys"]["sunrise"])
sunset_timestamp = datetime.datetime.fromtimestamp(data["sys"]["sunset"])
length_of_the_day = datetime.datetime.fromtimestamp(data["sys"]["sunset"]) - datetime.datetime.fromtimestamp(data["sys"]["sunrise"])
await message.reply(f'***{datetime.datetime.now().strftime("%Y-%m-%d %H:%M")}***\n'
f'Погода в городе: {city}\nТемпература:{temp}С {wd}\nВлажность: {humidity}\n'
f'Давление: {pressure} мм.рт.ст\nСкорость ветра: { wind_speed} м.с\n'
f'Восход: {sunsire_timestamp}\nЗакат: {sunset_timestamp}\nПродолжительность дня: {length_of_the_day}\n'
f'***Хорошего дня!***')
except:
await message.reply('\U00002620 Проверте название города \U00002620')
Но при запуске выдаёт ошибку:
Traceback (most recent call last):
File "tg_bot.py", line 15, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Перепробовал все методы с интернета. Ошибка остаётся