Beginner: Setup ✅

After scratching my head for a while over the various cloud notebook options, I wrote this blog post to hopefully help others:

3 Likes

Getting the following error when running the following commands from docs.fast.ai:

“conda install -c fastchan fastai”
or
“conda install -c fastchan fastai anaconda”

It happily chugs along downloading packages until it hits this:
------------- 219.9MB / 552.4MB @ 6.4MB/s cython-blis 29.5ssympy 17.0 B @ ??.?MB/s 0.3s
Multi-download failed. Reason: Transfer finalized, status: 404 [https://conda.anaconda.org/fastchan/win-64/sympy-1.11.1-py310h5588dad_2.tar.bz2] 17 bytes

So I assume that the link for sympy 1.11.1 in fastai ( I’m not very familiar with conda package dependency management structures ) is not an active link. Copy and pasting that link into a browser shows “release not found”.

I next wiped the environment, installed sympy seperately with "mamba install sympy " and then ran “mamba install -c fastchan fastai”

Now conda is throwing an “unexpected error” but doesn’t list the actual error. It only shows the environment variables.

I’ll try the “pytorch > pip install fastai” method next.

I’m posting this just in case anyone else sees or has seen these issues.

EDIT:

To be clear I’m trying to install this on a local environment, not one of the notebook hosting providers.

EDIT 2: edited for clarity.

SOLUTION:

PyTorch does not support python 3.11 so I re-created the environment with 3.9. I still got the sympy error, but this time after installing it separately I was able to install the rest of fastai using:

mamba install -c fastchan fastai -y

1 Like

Hi everyone,
I made my copy of the first lesson (Is it a bird?) on Kaggle, but am stuck on step 1:

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')

returns

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_18/1717929076.py in <module>
----> 1 from duckduckgo_search import ddg_images
      2 from fastcore.all import *
      3 
      4 def search_images(term, max_images=30):
      5     print(f"Searching for '{term}'")

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/__init__.py in <module>
      8 
      9 # isort: off
---> 10 from .compat import (
     11     ddg,
     12     ddg_answers,

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/compat.py in <module>
      2 import warnings
      3 
----> 4 from .duckduckgo_search import DDGS
      5 
      6 logger = logging.getLogger(__name__)

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in <module>
     11 
     12 import requests
---> 13 from requests.exceptions import HTTPError, JSONDecodeError, Timeout
     14 from requests.models import Response
     15 

ImportError: cannot import name 'JSONDecodeError' from 'requests.exceptions' (/opt/conda/lib/python3.7/site-packages/requests/exceptions.py)

In the next cell it says that I should try again, if I get a JSON error, but even after many tries it seems not to work. I am new to Python, so any hint is appreciated. Thanks!

1 Like

Yeah I am getting same error too
Please help

Me too - the exact same error.

@hewag1975, @Devesh2000, @oliverbogler,
As a diagnostic, select menu Run > Factory Reset, then add the following cell to the top of the notebook and execute it…

!pip install -U requests
import requests 
print("IMPORTED VERSION IS ", requests.__version__)
from requests.exceptions import JSONDecodeError
print("NOW OKAY")

and you might see…

Although you see it reports that version 2.31.0 was successfuly installed in the operating system, it shows an older version 2.26.0 was imported from a cache.

Now go Run > Restart and clear outputs, and run that first cell again. This time you should see…
image

and your original problem should also have been resolved.

The root cause was that history shows JSONDecodeError was not added until version 2.27.0

5 Likes

Thank you - that has indeed removed this error - much appreciated.

Does anyone have a functioning version of the 'Is it a bird? notebook on Kaggle that they can share? With bencoman’s help I no longer have the JSONDecodeError, but I cannot for the life of me get duck duck go to work - I believe that the code in the notebook provided with the course is out of date, but I have not been able to get even a simple image search to work…

1 Like

Thanks. It solved the error

Hey, I could just fix the problem by following the thread

You can comment on the search_images block and instead use this

!pip install fastbook

Import fastbook functions, in our case we’ll be using: search_images_ddg

from fastbook import *

create a function that will take an arbitrary search term and return a list of urls.

def search_images(term, max=30):
print(f"Searching for ‘{term}’")

search_images_ddg comes from fastbook: fastbook/utils.py at master · fastai/fastbook · GitHub

return search_images_ddg(term, max_images=max)

urls = search_images(“cats eating ice cream”)

3 Likes

Hey, Can you tell me how did you post the cell

Thanks. That worked - appreciate the tip.

I’m so confused as to where to get started? I have a Kaggle account, and in the book title ‘Running your first Notebook’ for lesson 1 there is an examples ‘00-intro’, but I can’t seem to find this anywhere? Meanwhile the links form Lesson 1 all point to ‘Is it a bird?’ or ‘Jupyter 101’?

Am I meant to pull something in from Github or something?

Kaggle doesn’t look anything like Jupyter? I’m not sure where I should be using Jupyter?

1 Like

Kaggle notebooks are in fact jupyter notebooks but the UI is a little different(and you are using Kaggles gpus). There are many ways to run the notebooks in the course: colab, kaggle, paperspace, locally. And any of these methods are fine.

1 Like

When I tried running the 2nd command on Kaggle from the 'Is it a bird?.. ’ notebook, I got an error related to dependencies (shown below); I ignored the error and tried to execute next cells and on 4th Cell, I got another error (also shown below)…Can you please help me understand the reason and how can I fix it?

Error on Running Command 2:
ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-io 0.21.0 requires tensorflow-io-gcs-filesystem==0.21.0, which is not installed.
explainable-ai-sdk 1.3.2 requires xai-image-widget, which is not installed.
dask-cudf 21.10.1 requires cupy-cuda114, which is not installed.
beatrix-jupyterlab 3.1.6 requires google-cloud-bigquery-storage, which is not installed.
tensorflow 2.6.2 requires numpy~=1.19.2, but you have numpy 1.20.3 which is incompatible.
tensorflow 2.6.2 requires six~=1.15.0, but you have six 1.16.0 which is incompatible.
tensorflow 2.6.2 requires typing-extensions~=3.7.4, but you have typing-extensions 3.10.0.2 which is incompatible.
tensorflow 2.6.2 requires wrapt~=1.12.1, but you have wrapt 1.13.3 which is incompatible.
tensorflow-transform 1.5.0 requires absl-py<0.13,>=0.9, but you have absl-py 0.15.0 which is incompatible.
tensorflow-transform 1.5.0 requires numpy<1.20,>=1.16, but you have numpy 1.20.3 which is incompatible.
tensorflow-transform 1.5.0 requires pyarrow<6,>=1, but you have pyarrow 6.0.1 which is incompatible.
tensorflow-transform 1.5.0 requires tensorflow!=2.0.,!=2.1.,!=2.2.,!=2.3.,!=2.4.,!=2.5.,!=2.6.*,<2.8,>=1.15.2, but you have tensorflow 2.6.2 which is incompatible.
tensorflow-serving-api 2.7.0 requires tensorflow<3,>=2.7.0, but you have tensorflow 2.6.2 which is incompatible.
gcsfs 2021.11.1 requires fsspec==2021.11.1, but you have fsspec 2022.2.0 which is incompatible.
flake8 4.0.1 requires importlib-metadata<4.3; python_version < “3.8”, but you have importlib-metadata 4.11.3 which is incompatible.
featuretools 1.6.0 requires numpy>=1.21.0, but you have numpy 1.20.3 which is incompatible.
dask-cudf 21.10.1 requires dask==2021.09.1, but you have dask 2022.2.0 which is incompatible.
dask-cudf 21.10.1 requires distributed==2021.09.1, but you have distributed 2022.2.0 which is incompatible.
apache-beam 2.34.0 requires dill<0.3.2,>=0.3.1.1, but you have dill 0.3.4 which is incompatible.
apache-beam 2.34.0 requires httplib2<0.20.0,>=0.8, but you have httplib2 0.20.2 which is incompatible.
apache-beam 2.34.0 requires pyarrow<6.0.0,>=0.15.1, but you have pyarrow 6.0.1 which is incompatible.
aioitertools 0.10.0 requires typing_extensions>=4.0; python_version < “3.10”, but you have typing-extensions 3.10.0.2 which is incompatible.
aiobotocore 2.1.2 requires botocore<1.23.25,>=1.23.24, but you have botocore 1.24.20 which is incompatible.

Error on Running Command 4:
/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
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)
311 cache = set()
312 for _ in range(10):
→ 313 resp = self._get_url(“GET”, “https://duckduckgo.com/i.js”, params=payload)
314 if resp is None:
315 break

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in _get_url(self, method, url, **kwargs)
68 logger.warning(f"_get_url() {url} {type(ex).name} {ex}")
69 if i >= 2 or “418” in str(ex):
—> 70 raise ex
71 sleep(3)
72 return None

/opt/conda/lib/python3.7/site-packages/duckduckgo_search/duckduckgo_search.py in _get_url(self, method, url, **kwargs)
62 if self._is_500_in_url(resp.url) or resp.status_code == 202:
63 raise requests.HTTPError
—> 64 resp.raise_for_status()
65 if resp.status_code == 200:
66 return resp

/opt/conda/lib/python3.7/site-packages/requests/models.py in raise_for_status(self)
951
952 if not self.encoding and self.content and len(self.content) > 3:
→ 953 # No encoding set. JSON RFC 4627 section 3 states we should expect
954 # UTF-8, -16 or -32. Detect which one to use; If the detection or
955 # decoding fails, fall back to self.text (using charset_normalizer to make

HTTPError: 403 Client Error: Forbidden for url: https://duckduckgo.com/i.js?l=wt-wt&o=json&s=0&q=bird+photos&vqd=4-117791107778443701629606176197253027971&f=%2C%2C%2C%2C%2C&p=1

1 Like

I am also facing this issue

Thank you for your time and work.

Question: I can run bird/forest in Kaggle and also locally in Jupyter Notebook.
My question is my Pytorch returned this
1.13.1+cpu
Will I be able to follow on locally with my CPU or shall I kaggle it ( i do not have a paid Kaggle subscription ).
Thank you.
Ido

Hello Community Friends,

I started yesterday and watched Video 1 from Part1 2022. After fixing a few errors that I got while trying to setup a fastpages blog on github I was finally able to setup this at - https://chetan2309.github.io/deeplearning/

However, the page looks off from styling perspective. Seems like some CSS is missing!!

Has anyone faced this issue before and can provide a workaround please?

Cheers,
Chetan

Did you ever get this figured out? I’m confused about the same thing. Where are the options/tutorials on the website?

Running locally on cpu will be extremely slow. Free options with GPU exist for running Jupyter notebooks. The common ones are Google Colab, Kaggle and a lesser known is https://studiolab.sagemaker.aws/.
(On each you will need to specifically select that you want it to run on GPU)

If you have a recent Nvidia card on your own machine, it may be a matter of reinstalling Pytorch with a cuda version that your card supports, follow install instructions from Pytorch.org

1 Like