Closed ahsanu123 closed 3 weeks ago
Hi @ahsanu123 can you try putting the imports under the %%blocks magic? So like this:
%%blocks
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import gradio as gr
def markPort(port):
if port == '':
return
...
and see if that works?
@abidlabs thanks for reply,
i already try to put import after %%block
but no improvment, still same
here is my kaggle: https://www.kaggle.com/code/caasperart/learnfft-spectogram
but, if iam not use magic %%block
, code is work as it
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/gradio/routes.py", line 401, in run_predict
event_data=event_data,
File "/opt/conda/lib/python3.7/site-packages/gradio/blocks.py", line 1076, in process_api
fn_index, inputs, iterator, request, event_id, event_data
File "/opt/conda/lib/python3.7/site-packages/gradio/blocks.py", line 885, in call_function
fn, *processed_input, limiter=self.limiter
File "/opt/conda/lib/python3.7/site-packages/anyio/to_thread.py", line 32, in run_sync
func, *args, cancellable=cancellable, limiter=limiter
File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "<string>", line 16, in plot_forecast
NameError: name 'np' is not defined
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/gradio/routes.py", line 401, in run_predict
event_data=event_data,
File "/opt/conda/lib/python3.7/site-packages/gradio/blocks.py", line 1076, in process_api
fn_index, inputs, iterator, request, event_id, event_data
File "/opt/conda/lib/python3.7/site-packages/gradio/blocks.py", line 885, in call_function
fn, *processed_input, limiter=self.limiter
File "/opt/conda/lib/python3.7/site-packages/anyio/to_thread.py", line 32, in run_sync
func, *args, cancellable=cancellable, limiter=limiter
File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "<string>", line 16, in plot_forecast
NameError: name 'np' is not defined
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/gradio/routes.py", line 401, in run_predict
event_data=event_data,
File "/opt/conda/lib/python3.7/site-packages/gradio/blocks.py", line 1076, in process_api
fn_index, inputs, iterator, request, event_id, event_data
File "/opt/conda/lib/python3.7/site-packages/gradio/blocks.py", line 885, in call_function
fn, *processed_input, limiter=self.limiter
File "/opt/conda/lib/python3.7/site-packages/anyio/to_thread.py", line 32, in run_sync
func, *args, cancellable=cancellable, limiter=limiter
File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/opt/conda/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "<string>", line 16, in plot_forecast
NameError: name 'np' is not defined
Hi, apologies for the late follow up. We haven't had a chance to look into this issue, but the Gradio codebase has changed quite significantly since this issue was created. Could you let us know if this is still an issue in the latest version of Gradio (pip install --upgrade gradio
)? Thanks!
close this, because project already complete.
thanks.
Describe the bug
hey, recently i started learn gradio on kaggle.com, when i was trying to learn plot with Block, i start with example from plot documentation (https://gradio.app/docs/#plot), i copy paste the code to my kaggle as shown below
(this also not working on colab)
i already import all library like
numpy, matplotlib.pyplot
etcwhen i run this code, gradio is run as expected, but when i click plot button the error is showing up, as shown below
as far i know error is say that numpy is not imported, is i miss something to run plot on platform like kaggle?
Is there an existing issue for this?
Reproduction
run this code in kaggle
then click plot button
Screenshot
No response
Logs
System Info
Severity
annoying