TypeError: expected str, bytes or os.PathLike object, not NoneType

I’m in dire need of help before I lose my mind please.

I’m getting the above error on Chapter 2 of the fastai 2020 course, when I attempt to download all the URLs for each search term of bears. I didn’t change any of the code provided, apart from entering my Bing Image Search Key:

if not path.exists():
    path.mkdir()
    for o in bear_types:
        dest = (path/o)
        dest.mkdir(exist_ok=True)
        results = search_images_bing(key, f'{o} bear')
        download_images(dest, urls=results.attrgot('contentUrl'))

Is the dest object really a NonType? I’ve tried pulling it apart and it looks like it does create the Path(‘bear/grizzly’) so i don’t see why this error is happening.

Screenshots attached. Any help would be greatly appreciated.

With the help of a friend we figured it out :slight_smile:
It looks like results.attrgot(‘contentUrl’) wasn’t the right attribute - it should be results.attrgot(‘content_url’)

1 Like