import os import dotenv # Force a clean write of the .env file with the key we found key = "AIzaSyAKw0taqvQqyFhN5cdz5iAtXj7hfCwdTHE" with open(".env", "w") as f: f.write(f"GOOGLE_API_KEY={key}\n") print("Rewrote .env file.") # Test loading it dotenv.load_dotenv(override=True) loaded_key = os.getenv("GOOGLE_API_KEY") print(f"Loaded Key: {repr(loaded_key)}") if loaded_key == key: print("MATCH! The environment variable is now correct.") else: print(f"MISMATCH! Environment variable is: {repr(loaded_key)}")