import spacy import subprocess import sys def download_spacy_model(model_name): print(f"Downloading and installing spaCy model: {model_name}") try: subprocess.check_call([sys.executable, "-m", "spacy", "download", model_name]) print(f"Successfully installed {model_name}") except subprocess.CalledProcessError: print(f"Error installing {model_name}. Please make sure you have the necessary permissions.") # Download and install English model download_spacy_model("en_core_web_sm") # Download and install French model download_spacy_model("fr_core_news_sm") # Load the models to verify installation try: nlp_en = spacy.load("en_core_web_sm") print("English model loaded successfully") except: print("Error loading English model") try: nlp_fr = spacy.load("fr_core_news_sm") print("French model loaded successfully") except: print("Error loading French model")