Error when using gradio, fastai on Hugging Face Space

Hi,

I followed lesson 2 and created a Gradio app, which works on my laptop.

However after pushing it to a Huggingface Gradio Space the build ends with an error:
ModuleNotFoundError: No module named ‘fastai’

I tried:
import os
os.system(‘pip install fastai’)
That results in an error as well.

What is required to get a Space with fastai and gradio installed? Or is there a different way?

thanks
Norbert

2 Likes

found it.
For dependencies you need to add the file “requirements.txt” It contains “fastai”

5 Likes

I highly recommend you finish till the end huggingface interface (API endpoint). Gradio says it ] works for 72 hours it did not for me. Huggingface actually works even after a month. A great place to show your work.

Where I can find the “requirements.txt”?

Hi, here is my requirement.txt that I used for the deployment.

3 Likes

Thank you very much! I already push the model to my Space on huggingface and it works!

2 Likes

I’m glad it worked!
Now you can share your work on this post if you don’t mind so that everyone can check it out! :smile:

1 Like

Hi, i am getting this error even after using requirements.txt

Runtime error

Traceback (most recent call last): File “app.py”, line 7, in from fastai.vision.all import * ModuleNotFoundError: No module named ‘fastai’

Did you ever figure this out ?

You need to go into your Space and find the “App” tab, next to it is a “File” tab:
click on “File”, then click “Add file”.
An editor opens up.
enter file name as “requirements.txt”
in the body, type “fastai”
then complete by clicking “create file”

1 Like

me too, did you figure this out ?

Farai, I could be wrong, but check that the fastai module is installed.
I was running the code locally and had to therefore install the fastai module locally.
Go to the environment that you’ve created and use pip install -Uqq fastai

Thanks!
adding requirements.txt with fastai did the trick!