简体   繁体   中英

Importing tkinter in Flask

I'm new to PythonAnywhere, and when I try to import tkinter using Flask putting from tkinter import * after the line from flask import Flask , it shows an error saying: " 'from tkinter import *' used; unable to detect undefined names ".

How do I have to import tkinter, then?

Your code editor is automatically running a linter like flake8 or pyflakes , and it is this linter that tells you that it cannot detect common coding errors because you are using a from <modulename> import * statement. That's because a linter cannot know up front what names that statement will import.

In other words, this is not a Python error . Nor is it specific to PythonAnywhere.

You can avoid the message by importing only what you are actually using in your code:

from tkinter import Frame, StringVar, Label

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM