gradio: AttributeError: module 'gradio' has no attribute 'Interface'

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am trying the following in a Windows machine. Installed gradio using ‘pip install gradio’ to an environment and running the following code in Pycharm.

import gradio as gr

from gradio import Interface

def greet(name): return "Hello " + name + “!!”

iface = gr.Interface(fn=greet,inputs=“text”,outputs=“text”) iface.launch()

Getting error AttributeError: module ‘gradio’ has no attribute ‘Interface’ I then tried the following and still getting error

import gradio as gr

from gradio import Interface

def greet(name): return "Hello " + name + “!!”

iface = Interface(fn=greet,inputs=“text”,outputs=“text”) iface.launch()

Error: ImportError: cannot import name ‘Interface’ from ‘gradio’

Reproduction

import gradio as gr

from gradio import Interface

def greet(name): return "Hello " + name + “!!”

iface = gr.Interface(fn=greet,inputs=“text”,outputs=“text”) iface.launch()

Screenshot

No response

Logs

No response

System Info

gradio: 2.9.4
Windows

Severity

critical

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Hello. Thank you for looking into this issue. I re-installed, but that didn’t solve. However, this is a new Python gotcha! My Python script name was - gradio.py. So when I was using import gradio as gr, it was importing but confusing with the file name. Changed the file name to gadio_learn.py and it works like a charm. Posting so that others don’t waste time like I did…

This is usually caused by gradio not being installed correctly in the python environment.

Can you try pip uninstall gradio and then rerun pip install gradio and let us know if you are still seeing this?

Related: #613

I was doing the same thing lol

Hello. Thank you for looking into this issue. I re-installed, but that didn’t solve. However, this is a new Python gotcha! My Python script name was - gradio.py. So when I was using import gradio as gr, it was importing but confusing with the file name. Changed the file name to gadio_learn.py and it works like a charm. Posting so that others don’t waste time like I did…

Hello. Thank you for looking into this issue. I re-installed, but that didn’t solve. However, this is a new Python gotcha! My Python script name was - gradio.py. So when I was using import gradio as gr, it was importing but confusing with the file name. Changed the file name to gadio_learn.py and it works like a charm. Posting so that others don’t waste time like I did…

Haha, this reply saves my day. Thank you so much!

Thank you very much! this really help