Shreeram
(Shreeram)
April 2, 2021, 5:16pm
1
Can someone please help with this?
urls = search_images_ddg('grizzly bear', max_images=100)
len(urls),urls[0]s
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-fe39ec9b75f1> in <module>
----> 1 urls = search_images_ddg('grizzly bear', max_images=100)
2 len(urls),urls[0]
~\anaconda3\lib\site-packages\fastbook\__init__.py in search_images_ddg(term, max_images)
55 assert max_images<1000
56 url = 'https://duckduckgo.com/'
---> 57 res = urlread(url,data={'q':term}).decode()
58 searchObj = re.search(r'vqd=([\d-]+)\&', res)
59 assert searchObj
AttributeError: 'str' object has no attribute 'decode'
1 Like
Amadeus
(Amadeus Hovekamp)
April 2, 2021, 8:28pm
2
Can you please prit what urlread returns?
print(urlread(url,data={‘q’:term})
Maybe it returned an error message (a string) that cannot be decoded?
1 Like
BresNet
(Keno)
April 3, 2021, 3:00am
3
urlread
now returns urls decoded as str per default, you can remove the .decode()
from the function and it works.
2 Likes
Shreeram
(Shreeram)
April 3, 2021, 1:02pm
4
Removed the .decode() recommended by @BresNet , fixed the issue.
seems that the search_images_ddg()
in (even the latest) fastbook
still has the “.decode” in it.
urls = search_images_ddg('grizzly bear', max_images=100)
len(ims)
urls = search_images_ddg('grizzly bear', max_images=100)
len(ims)
urls = search_images_ddg('grizzly bear', max_images=100)
len(ims)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-e3064b7d2a3d> in <module>
----> 1 urls = search_images_ddg('grizzly bear', max_images=100)
2 len(ims)
~/envs/fastai/lib/python3.8/site-packages/fastbook/__init__.py in search_images_ddg(term, max_images)
55 assert max_images<1000
56 url = 'https://duckduckgo.com/'
---> 57 res = urlread(url,data={'q':term}).decode()
58 searchObj = re.search(r'vqd=([\d-]+)\&', res)
59 assert searchObj
AttributeError: 'str' object has no attribute 'decode'
Ztrimus
(Saurabh Zinjad)
June 5, 2021, 6:37am
6
How do you remove the .decode
function, since it is in /usr/local/lib/python3.7/dist-packages/fastbook/__init__.py
which in the library path?
is it okay to remove it from inbuilt files?
delgermurun
(Delgermurun Purevkhuu)
June 24, 2021, 6:35pm
7
It is fixed in the book’s repo. I guess it hasn’t published to pypy
yet.
You can copy the whole function from fastbook/utils.py at 8be580737ee0cc17746a5ed68283150d489b3dc4 · fastai/fastbook · GitHub , add a new cell in a notebook, and run it. It will override the installed package’s function.
1 Like
miwojc
July 21, 2021, 5:25am
8
Thank you @delgermurun for fixing it. how can we publish it to pypy please?