Lesson 2 official topic

Interesting. Are you also using Kaggle or completely your macbook?

With your code snippet I get the same outcome: 1st run works, any after DDGSException: No results found

The ‘fix’ I found still works for me at least.

This is the complete error I get if anyone else can help. I’ve tried both Paperspace and Kaggle. Internet is enabled for both and I verified it as well. Turning off internet yields the same error message, but the cell runs for a few seconds longer.

---------------------------------------------------------------------------
DDGSException                             Traceback (most recent call last)
/tmp/ipykernel_36/605048266.py in <cell line: 0>()
----> 1 urls = search_images('dog photos', max_images=10)
      2 print(urls[0])
      3 
      4 dest = 'bird.jpg'
      5 download_url(urls[0], dest, show_progress=False)

/tmp/ipykernel_36/1439059728.py in search_images(keywords, max_images)
      4 from fastai.vision.all import *
      5 
----> 6 def search_images(keywords, max_images=200): return L(DDGS().images(keywords, max_results=max_images)).itemgot('image')
      7 
      8 urls = search_images('bird photos', max_images=10)

/usr/local/lib/python3.11/dist-packages/ddgs/ddgs.py in images(self, query, **kwargs)
    222     def images(self, query: str, **kwargs: Any) -> list[dict[str, Any]]:
    223         """Perform an image search."""
--> 224         return self._search("images", query, **kwargs)
    225 
    226     def news(self, query: str, **kwargs: Any) -> list[dict[str, Any]]:

/usr/local/lib/python3.11/dist-packages/ddgs/ddgs.py in _search(self, category, query, keywords, region, safesearch, timelimit, max_results, page, backend, **kwargs)
    214         if "timed out" in f"{err}":
    215             raise TimeoutException(err)
--> 216         raise DDGSException(err or "No results found.")
    217 
    218     def text(self, query: str, **kwargs: Any) -> list[dict[str, Any]]:

DDGSException: No results found.

Upon further testing it seems like the argument I need is color

# This works for me 
results = DDGS().images(
    query="Grizzly Bear",
    color="color"
)
# This does not
results = DDGS().images(
    query="Grizzly Bear",
    color="color"
)

So if anyone else runs into this issue you can use

def search_images(keywords, max_images=10, color=color'):
    results = DDGS().images(
        query=keywords,
        max_results=max_images,
        color=color,
    )
    return L(results).itemgot('image')

I’ve also verified by running other notebooks linked here that didn’t work for me before and I updated the definition of search_images to include color.