ImportError: No module named flask_restful

ImportError: No module named flask_restful

我正在尝试部署 appengine flex python 应用程序,但部署后 Stackdriver 日志 stderr 中出现以下内容

  File "/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/env/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/env/local/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app
    __import__(module)
  File "/home/vmagent/app/my_service/entry_point.py", line 5, in <module>
    import flask_restful as restful
ImportError: No module named flask_restful

entry_point.py 在第 5 行有

import flask_restful as restful

我的requirement.txt有

Flask-RESTful==0.3.6
gunicorn==19.7.1

不确定为什么它仍然抱怨 Flask-Restful

导入是 case sensitive on certain platforms, namely Linux (Windows and Mac may or may not care about case). The package Flask-RESTful isn't all lowercase like most packages (as per PEP 8 建议),因此 import flask_restful as restful 除非使用正确的大小写,否则会产生导入错误。

ImportError: No module named flask_restful

您似乎没有安装 flask_restful,要安装 运行:

pip install flask-restful

在您的终端,然后运行您的应用。

文档:https://flask-restful.readthedocs.io/en/latest/installation.html

我遇到了同样的问题...我 运行 我的应用程序使用 Visual Studio 代码的 "Play" 按钮并被卡住了。一切都已经安装... 过了一会儿我意识到我必须使用 IDE 的控制台并从那里启动程序:

python App.py

我是运行它在虚拟环境下

  1. 基本上你的项目根目录与你的python不匹配 此特定 (flask_restful) 包的根目录,

  2. 卸载 python 应用程序并在 window 程序文件上重新安装它,您 应该在 window 程序中安装 python 而不是单独安装

    我通过这个程序解决了它(快乐编码)