How to debug Spaces on hf.co

I have a model/app deployment that works perfectly on my local machine and errors out after 1-2 seconds upon pressing “submit” on the hosted Gradio app. Where can I check a log of what is going on? I have no clue… and the documentation for spaces seems incomplete, at least from what I found.

Hello @pszemraj :hugs:
Can you send me the link to your Space?
If you’re using it with gradio try setting debug = True when launching (one thing I can think of).

1 Like

As @merve mentioned, setting debug=True is a good idea. On top of that, once you see the fail message, you can click in “Running” or “Build error” next to the like count, and that will actually show you the logs. FYI we have an internal PR to make this a clear button.

Eg, for your space, I see the following error

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/home/user/.local/lib/python3.8/site-packages/nltk/corpus/util.py”, line 84, in __load
root = nltk.data.find(f"{self.subdir}/{zip_name}")
File “/home/user/.local/lib/python3.8/site-packages/nltk/data.py”, line 583, in find
raise LookupError(resource_not_found)
LookupError:


Resource e[93mstopwordse[0m not found.
Please use the NLTK Downloader to obtain the resource:

e[31m>>> import nltk

nltk.download(‘stopwords’)
e[0m
For more information see: NLTK :: Installing NLTK Data

Attempted to load e[93mcorpora/stopwords.zip/stopwords/e[0m

Searched in:
- ‘/home/user/nltk_data’
- ‘/usr/local/nltk_data’
- ‘/usr/local/share/nltk_data’
- ‘/usr/local/lib/nltk_data’
- ‘/usr/share/nltk_data’
- ‘/usr/local/share/nltk_data’
- ‘/usr/lib/nltk_data’
- ‘/usr/local/lib/nltk_data’


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/user/.local/lib/python3.8/site-packages/gradio/networking.py”, line 196, in predict
prediction, durations = app.interface.process(raw_input)
File “/home/user/.local/lib/python3.8/site-packages/gradio/interface.py”, line 373, in process
predictions, durations = self.run_prediction(
File “/home/user/.local/lib/python3.8/site-packages/gradio/interface.py”, line 339, in run_prediction
prediction = predict_fn(*processed_input)
File “app.py”, line 86, in chat
response = ask_gpt(message)
File “app.py”, line 57, in ask_gpt
prompt = clean(message) # clean user input
File “/home/user/.local/lib/python3.8/site-packages/cleantext/cleantext.py”, line 8, in clean
stop_words = nltk.corpus.stopwords.words(stp_lang)
File “/home/user/.local/lib/python3.8/site-packages/nltk/corpus/util.py”, line 121, in getattr
self.__load()
File “/home/user/.local/lib/python3.8/site-packages/nltk/corpus/util.py”, line 86, in __load
raise e
File “/home/user/.local/lib/python3.8/site-packages/nltk/corpus/util.py”, line 81, in __load
root = nltk.data.find(f"{self.subdir}/{self.__name}")
File “/home/user/.local/lib/python3.8/site-packages/nltk/data.py”, line 583, in find
raise LookupError(resource_not_found)
LookupError:


Resource e[93mstopwordse[0m not found.
Please use the NLTK Downloader to obtain the resource:

e[31m>>> import nltk

nltk.download(‘stopwords’)
e[0m
For more information see: NLTK :: Installing NLTK Data

Attempted to load e[93mcorpora/stopwordse[0m

Searched in:
- ‘/home/user/nltk_data’
- ‘/usr/local/nltk_data’
- ‘/usr/local/share/nltk_data’
- ‘/usr/local/lib/nltk_data’
- ‘/usr/share/nltk_data’
- ‘/usr/local/share/nltk_data’
- ‘/usr/lib/nltk_data’
- ‘/usr/local/lib/nltk_data’

Ah I completely forgot this! :sweat_smile:

You might have NLTK packages that are on your local but not Spaces, that’s why it works on local imo.

1 Like

Thanks so much, and sorry for my super late response. Adding some details for you / others that may come across this post later:

  • the space in question was this one
  • nltk packages were indeed the culprit - after installing, it worked fine.
  • what I was ultimately looking for, though, has since been handled/upgraded. It is now much more obvious how to see the logs (see below image), which I struggled to find when you had to click on the “error” icon to see logs.
1 Like