Beginner: Setup ✅

Possibly you haven’t enabled external internet access.

2 Likes

Thank you very much!! Now it is working. Best.

Josep Mencion Seguranyes

1 Like

Hey guys, I’m trying to do lesson 1 but am having some trouble with the setup in Kaggle. I try to run the various code snippets and receive errors for effectively everything. It’s as if I’m not importing the requisite library(s), but not sure what exactly is up. Any help would be appreciated.

Hey, following up from my previous post – having trouble with the setup. When I try to import the fastbook library I get the following error. Appreciate some help!

It looks like you haven’t defined urls yet. If you are following Jeremy’s notebook “Is it a bird?”, urls is defined as a list of image URLs returned by the search_images function:

#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]

Here is the code for the search_images function:

from duckduckgo_search import ddg_images
from fastcore.all import *

def search_images(term, max_images=30):
    print(f"Searching for '{term}'")
    return L(ddg_images(term, max_results=max_images)).itemgot('image')
1 Like

The likely problem here is that there is that [ -e /content ] returns false, so it doesn’t run pip install -Uqq fastbook because of the && conditional (it will only run the pip install if [ -e /content ] is truthy). Instead, try running just the following:

! pip install -Uqq fastbook

And see if that resolves your issue.

I found this forum post which explains this in more detail.

Hey, thanks for getting back! I’m actually just following along in the Kaggle notebook so all the code is there (i.e. everything, including urls, is predefined). Not sure why it’s not working!

Getting the below 403 error when trying to run the below cell. I used the run all function to ensure all prior cells had been executed, ensured internet was turned on, and ran it a few times even though this isnt a JSON error. New to this and not sure what to do here. Thanks!

#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]

1 Like

See message by Devesh2000 on May 23 for the fix

1 Like

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?