Beginner: Using Colab or Kaggle ✅

I’m running into the same issue — Did you find a solution?

@LukaszF @devastador try using the following definition of search_images—note the use of DDGS from the duckduckgo_search package:

from duckduckgo_search import DDGS

def search_images(term, max_images=30):
  print(f"Searching for ‘{term}’")
  with DDGS() as ddgs:
        return L(ddgs.images(term, max_results=max_images)).itemgot('image')

Here’s a colab notebook using that function to get images for the Chapter 2 bears classifier.

Hi @vbakshi
Thank you for trying to help.
When I changed the function I get this error instead


Which is weird because I checked the documentation and this parameter is standard one.

When I remove the parameter ‘max_results’ I get the same HTTPerror as previously:

Can you share a link to the notebook you are working in?

Sure:
https://www.kaggle.com/code/lukaszfrydrych/notebook7cc4420384/edit

It gives this error—perhaps it’s not a public notebook yet?

When you click “Share” at the top right you can select “Public”:

Updated, thanks.

1 Like

Yeah I initially got the same error.

It’s interesting that in Google Colab (link to notebook) I run the same code and it works.

I think it’s a version issue.

In Google Colab, it installs version 4.4.3

While in Kaggle the same line of code installs version 3.8.5

When I try to run the following in Kaggle:

! pip install duckduckgo_search==4.4.3

I got the error:

ERROR: Could not find a version that satisfies the requirement duckduckgo_search==4.4.3 (from versions: 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.9.5, 1.0, 1.1, 1.2, 1.3, 1.3.5, 1.4, 1.5, 1.5.1, 1.5.2, 1.6, 1.6.2, 1.7.1, 1.8, 1.8.1, 1.8.2, 2.0.2, 2.1.3, 2.2.0, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.5.0, 2.6.0, 2.6.1, 2.7.0, 2.8.0, 2.8.1, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.9.4, 2.9.5, 3.0.2, 3.1.1, 3.2.0, 3.3.0, 3.4.1, 3.5.0, 3.6.0, 3.7.0, 3.7.1, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5)
ERROR: No matching distribution found for duckduckgo_search==4.4.3

It turns out that it was a Kaggle notebook setting issue! If you open the notebook settings in Kaggle (left-pointing arrow on the bottom right) it will open up this pane—scroll down to “Environment” and select “Always use latest environment”, then restart the session and run the code and it should work:

1 Like

@vbakshi
Thank you! It helped!
I actually tried changing the encironment to the latest but did not update the function itself.
So, there were actually 2 problems that needed to be solved.
Thank you once again!

1 Like

anyone know the answer to this quesetion?

I was able to produce a minimal reproducible example in this notebook with the 4 lines of code for training the text_classifier.

Hello there, Just a minor doubt. I was doing image classification in kaggle(notebook).

During training I was using the GPU T4*2 but only one gpu was actively running while the other one is completely idle.

So the doubt: Should I change/optimize the code or change GPU type? Any heuristic to to follow!

1 Like

Am having the error below. Please any help

It’s because the library used to find images using duckduckgo is outdated. Here’s an updated version of the method that you can use which will allow you to search for images:

from duckduckgo_search import DDGS
from fastcore.all import *

def searchImages(searchTerm, maxImages=30):
  print(f"Searching for '{searchTerm}'")
  results = L(DDGS().images(
    keywords=searchTerm,
    max_results=maxImages
    )).itemgot('image')

  return results

Note, I changed the name of the method and parameter because underscores are :nauseated_face: but this will allow you to get past the above error you’re getting.

1 Like

You can use my updated searchImages method: Beginner: Using Colab or Kaggle ✅ - #160 by suprith

How do I solve this?

I’m wondering what you all are using as the source for and what platform your using for the course notebooks. It seems that every direction that I go I end up with seems to be outdated execution environments. Specifically, the imports and pip installs fail because of outdated notebooks or the libraries are the wrong versions. It’s been a very frustraiting and disappointing experience for me. I hope that someone can point me in a better, more current direction.

Something is odd with kaggle with duckduckgo search library. With the updated search image function posted above I just get a different error. To get around this I removed max results and it just gave me a 403 from kaggle trying to access duck duck go. Doing this from a local notebook it was fine though. I’ll continue from there.