ImportError: cannot import name 'serve' from 'waitress'

ImportError: cannot import name 'serve' from 'waitress'

from waitress import serve              # error line 
import app                              # python file where flask code is written
serve(app.app,port=8000,thread=55) 
  1. Python 版本:3.7
  2. 女服务员版本:尝试使用 1.4.1 和 1.3.0*

堆栈跟踪

C:\Users\ashish.kamble\ModelDeployment\Scripts\python.exe C:/Users/ashish.kamble/PycharmProjects/ModelDeployment/waitress.py
Traceback (most recent call last):
  File "C:/Users/ashish.kamble/PycharmProjects/ModelDeployment/waitress.py", line 1, in <module>
    from waitress import serve
  File "C:\Users\ashish.kamble\PycharmProjects\ModelDeployment\waitress.py", line 1, in <module>
    from waitress import serve
ImportError: cannot import name 'serve' from 'waitress' (C:\Users\ashish.kamble\PycharmProjects\ModelDeployment\waitress.py)

Process finished with exit code 1

您的错误发生是因为您的文件名为 waitress.py

当您 运行 您的代码时,您的 waitress 关键字作为文件的对象。如果你想摆脱那个错误 重命名你的 python 文件 到它不代表你的图书馆。

添加 -: 最好使用Pycharm 项目解释器安装库。按照这些 使用解释器安装库。