The library has changed it seems I used this instead:
from ddgs import DDGS
def search_images(keywords, max_images = 200):
results = DDGS().images(keywords, max_results = max_images)
return L(r[āimageā] for r in results if āimageā in r)
The error means your code is timing out while trying to reach DuckDuckGo serversālikely due to network issues, restrictions, or temporary service problems. Try restarting your Colab runtime, checking your internet, or switching to a different library like bing-image-downloader. Using a proxy or adding retry logic can also help. Want a quick workaround? I can help rework your code.
I have been fighting this issue myself. It seems like most duck-duck-go solutions will fail from Colab because they filter traffic and Colab reuses IPs or something. Iāve been trying with Openverse but things are not easy either (or limited later, such as getting good URLs from Flicker which then blocks downloads).
For something more productive Iād consider Bing or similar (involves registering on Azure). Otherwise I kind of gave up and decided to use Imageye to download mid-sized images semi-manually: you do image search (DDG or whatever) and scroll until you see enough of them. Then Imageye downloads them in batch, saving quite a lot of time, but resulting in aprox 500x500 images.
Really interested in real solutions for this basic problem that work in 2025.