Beginner: Setup ✅

I’m using Kaggle notebooks but am not seeing a complete list of all the functions available when I press H, nor do I see any option to view Kaggle keyboard shortcuts. Does anyone have any suggestions regarding this?

Also, how do I make a new post to the forum and where is the cats and dogs notebook referenced in Chapter 1 of the textbook?

Hey all, Need some help with “Is it a bird?”

Kaggle, Brave Browser, Intel Mac.

In the “Is it a bird?” Notebook, when I run the cells sequentially, and run the following cell:

#NB: `search_images` depends on duckduckgo.com, which doesn't always return correct responses.
#    If you get a JSON error, just try running it again (it may take a couple of tries).
urls = search_images('bird photos', max_images=1)
urls[0]

I get the following Error:

Searching for 'bird photos'
/opt/conda/lib/python3.7/site-packages/duckduckgo_search/compat.py:60: UserWarning: ddg_images is deprecated. Use DDGS().images() generator
  warnings.warn("ddg_images is deprecated. Use DDGS().images() generator")
/opt/conda/lib/python3.7/site-packages/duckduckgo_search/compat.py:64: UserWarning: parameter page is deprecated
  warnings.warn("parameter page is deprecated")
/opt/conda/lib/python3.7/site-packages/duckduckgo_search/compat.py:66: UserWarning: parameter max_results is deprecated
  warnings.warn("parameter max_results is deprecated")
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
/tmp/ipykernel_17/2432147335.py in <module>
      1 #NB: `search_images` depends on duckduckgo.com, which doesn't always return correct responses.
      2 #    If you get a JSON error, just try running it again (it may take a couple of tries).
----> 3 urls = search_images('bird photos', max_images=1)
      4 urls[0]

/tmp/ipykernel_17/1717929076.py in search_images(term, max_images)
      4 def search_images(term, max_images=30):
      5     print(f"Searching for '{term}'")
----> 6     return L(ddg_images(term, max_results=max_images)).itemgot('image')

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/compat.py in ddg_images(keywords, region, safesearch, time, size, color, type_image, layout, license_image, max_results, page, output, download)
     80         type_image=type_image,
     81         layout=layout,
---> 82         license_image=license_image,
     83     ):
     84         results.append(r)

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in images(self, keywords, region, safesearch, timelimit, size, color, type_image, layout, license_image)
    403         assert keywords, "keywords is mandatory"
    404 
--> 405         vqd = self._get_vqd(keywords)
    406         assert vqd, "error in getting vqd"
    407 

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in _get_vqd(self, keywords)
     93     def _get_vqd(self, keywords: str) -> Optional[str]:
     94         """Get vqd value for a search query."""
---> 95         resp = self._get_url("POST", "https://duckduckgo.com", data={"q": keywords})
     96         if resp:
     97             for c1, c2 in (

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in _get_url(self, method, url, **kwargs)
     87                 logger.warning(f"_get_url() {url} {type(ex).__name__} {ex}")
     88                 if i >= 2 or "418" in str(ex):
---> 89                     raise ex
     90             sleep(3)
     91         return None

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in _get_url(self, method, url, **kwargs)
     80                 )
     81                 if self._is_500_in_url(str(resp.url)) or resp.status_code == 202:
---> 82                     raise httpx._exceptions.HTTPError("")
     83                 resp.raise_for_status()
     84                 if resp.status_code == 200:

HTTPError: 

It appears to be an issue with the image license?

It’s returning an HTTPError.

Any suggestions how to fix this?

Thank You!

It’s because the pinned environment is running an older version of python which is not supported by recent versions of the duckduckgo_search package. It appears the duckduckgo_search package version that is supported by the older version of python no longer works with the duckduckgo service itself.

I switched from the pinned environment to the latest environment and the notebook ran without issue.

4 Likes

That worked! Thank you! :pray:

Has anybody a problem with rendering fonts in the console of the Jupyter Notebook as workspace at paperspace VM ? I must work with 2 opened cards in the FF browser. Terminal works well in paperspace notebook, but I prefer to use Jupyter.

This fixed the issue I was having. Thanks!

Hello all! I’m trying to start this course using Kaggle. Is it still a recommended environment? I’m in a copy of Jeremy’s “Is it a bird?” notebook; many people seem to be having version compatibility problems that remind me of DLL hell. I started out with the environment version pinned, and I don’t understand why that’s not keeping the dependencies stable and compatible. Reading this thread, I see some people have had luck by switching to the “Always use latest environment” setting. Using this approach, on a fresh copy of Jeremy’s notebook, I get a different error. Interactively I see:

Trying to save my notebook copy, I get an extended version of an error message with a long stack trace. Given my background (years at Microsoft), these errors seem like showstoppers for a learning environment. It’s not that I can’t muddle through troubleshooting, and I’m sure there are others who have encountered the same messages, but isn’t there a systemic way to freeze the dependencies on a stable version for the learning experience?

I’m guessing the answer is that there are dependencies, such as duckduckgo.com, which kaggle can’t freeze. But even that is questionable in my mind. The errors I get seem to very a lot. Now I’m seeing

ImportError: cannot import name ‘ddg_images’ from ‘duckduckgo_search’ (/opt/conda/lib/python3.10/site-packages/duckduckgo_search/init.py)

My copy of: Is it a bird? Creating a model from your own data | Kaggle

I am having the same problem reported by @burtharris. For last 3 hours I am trying to run the first notebook and am failing. I downloaded the notebook locally and tried to run there also and ran into problem after problem. I am using Mac and last I gave up when I just couldn’t install bcolz! I get this error called “ERROR: Failed building wheel for bcolz”. On Kaggle.com I get the error saying cannot import name "ddg_images’… I have tried changing the option suggested by @matdmiller but didn’t work as well. Will appreciate any help. Thanks.

Try this:

In addition to unpinning the environment there are also some minor code edits needed because the duckduckgo_search package deprecated the function used in the notebook. Here are the changes needed to make the notebook run:

# from duckduckgo_search import ddg_images
from duckduckgo_search import DDGS
from fastcore.all import *

ddgs = DDGS()

def search_images(term, max_images=30):
    print(f"Searching for '{term}'")
#     return L(ddg_images(term, max_results=max_images)).itemgot('image')
    return L(ddgs.images(keywords=term, max_results=max_images)).itemgot('image')
4 Likes

Thank you so much @matdmiller with the changes suggested by you it worked perfectly. I am following both the online video and book. The book gives an example of training the model to detect between cat and dog. That notebook is in the clean folder ( https://github.com/fastai/fastbook/blob/master/clean/01_intro.ipynb ). I am running into the problem at the first cell itself. I am getting error “ModuleNotFoundError: No module named ‘fastbook’”. Any idea how to overcome that?

It can’t find the fastbook module so you need to install it.

pip install -U fastbook

It worked. Thanks. Now I am stuck in cell “img = PILImage.create(image_cat())”. It says image_cat undefined.

Meanwhile I am trying to replicate the setup locally on my Mac. I installed everything but import fastai fails in jupypter notebook but strangely it works on terminal window but fails in Jupyter notebook. I installed fastai using pip install fastai in notebook itself. Also, if run !pip list | grep fastai I can see 2.7.13 being printed. I have restarted kernel mulitple times, uninstalled fastai using pip uninstall and installed again but same error! Any clue? Thanks again in advance for help!

Thank you, Mat. Success.

I’m still getting a few warnings about version conflicts between SciPy and NumPy, but I gather these are not a big deal for this example.

It would be great if @jeremy could update his notebook to address these changes. I’m not sure of the interactions between Kaggle and GitHub. Is this the sort of thing a pull request might help with?

1 Like

Hi Fabio - I was relieved to see that I’m not the only one having difficulty with this. Did you ever figure it out? Thanks!

They used to have the tutorials on the older version of the course.fast.ai website, which is probably what that is referring to. In the fastai Lesson 0 video, Jeremy walks through some of the options that were available at the time. The two options I use to run the course code is Google Colab and Kaggle, but there are other options that are shown in the video.

Does anyone know if a new version of this course will be coming out for the year 2024 or if it would be good to start with the latest course on the website now? I believe the latest course is either from 2022 or 2023. I just don’t want to start this course that is a year old if a new course is planned to be released later this year or in a few months from now.

Does anyone know or could one of the makers of this course comment on this? Thanks.

The official repo has a number of open PRs. The last time a PR was accepted was in April of '22. If you don’t want to wait, theoretically someone could fork the repo and make any necessary updates. We could have a community-maintained version of this course. :slight_smile:

Thank you so much @vbakshi ! I was missing the crucial step of changing the ‘Runtime’ option to GPU.

1 Like

This was critical for me! Thank you.

1 Like