pythonvisual-studio-codeairflowairflow-webserver

how do i import xmltodict on python 3.11.4(virtual venv) because rn it's giving me an error


I'm trying to make a project on vs code using airflow and here is the code.

from airflow.decorators import dag, task
import pendulum

import requests
import xmltodict
#decorator creation
@dag (
    dag_id = "podcast_summary2",
    schedule_interval = "@daily",
    start_data= pendulum.datetime(2022,5,31),
    catchup=False

)
def podcast_summary2():
    @task()
    def get_episodes():
        data = requests.get("https://marketplace.org/feed/podcast/marketplace/")
        #feed = xmltodict.parse(data.text)
        episodes = feed["rss"]["channel"]["item"]
        print(f"Found{len(episodes)} episodes.")
        return episodes
    podcast_episodes = get_episodes()


summary = podcast_summary2()

enter image description here

I was expecting it to import xmltodict, but it won't on this python version but it will for python 3.9


Solution

  • Whichever python interpreter you use you need to install the xmltodict package for that. Or choose an interpreter environment that already has the xmltodict package installed. Obviously you don't.

    Also need to pay attention to the use of Python extensions to execute scripts (Run Python File).