Python 没有名为 flask.ext.restful 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27899911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 02:25:51  来源:igfitidea点击:

No module named flask.ext.restful

pythonflask

提问by WebQube

trying to run a server

尝试运行服务器

    (dal)?  Server (master) python mainDAL.py                                                        ? ?
    Traceback (most recent call last):
      File "mainDAL.py", line 4, in <module>
        from flask.ext import restful
      File "/Users/partuck/.virtualenvs/dal/lib/python2.7/site-packages/flask/exthook.py", line 87, in load_module
        raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.restful

my pip include Flask with the latest version. what I don't understand is what is this what is this restful module.

我的 pip 包括最新版本的 Flask。我不明白的是这是什么,这个宁静的模块是什么。

read here http://flask-restful.readthedocs.org/en/latest/api.html#id1that it exists.

在这里阅读http://flask-restful.readthedocs.org/en/latest/api.html#id1它存在。

 (dal)?  Server (master) pip freeze                                                               ? ?
Flask==0.10.1
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
mimerender==0.5.4
pbr==0.10.7
pipdeptree==0.4.2
pymongo==2.7.2
python-dateutil==2.4.0
python-mimeparse==0.1.4
six==1.9.0
SQLAlchemy==0.9.8
stevedore==1.2.0
virtualenv==12.0.5
virtualenv-clone==0.2.5
virtualenvwrapper==4.3.2
Werkzeug==0.9.6

采纳答案by Ffisegydd

You have installed Flask, but you haven't installed Flask-RESTful, it's not in your pip freezelist.

您已经安装了 Flask,但是您还没有安装Flask-RESTful,它不在您的pip freeze列表中。

You can installit with pip install flask-restful.

你可以安装pip install flask-restful

回答by Harry_pb

I encountered the same problem and above code was unable to solve my problem. You can directly apply the below code:-

我遇到了同样的问题,上面的代码无法解决我的问题。您可以直接应用以下代码:-

pip install Flask-API

This will help you install Flask-API and you don't need to individually update/load modules.

这将帮助您安装 Flask-API,并且您不需要单独更新/加载模块。

回答by Sphinx

I just met similar problem, My native language is not english, in that tutorial, it said uses flask restful by from flask.ext import restful, but it will throw out ModuleNotFoundError: No module named 'flask.ext'.

我刚刚遇到了类似的问题,我的母语不是英语,在那个教程中,它说使用flask restful by from flask.ext import restful,但它会抛出ModuleNotFoundError: No module named 'flask.ext'

Finally in Flask-RESTful: english version Tutorial,

最后在Flask-RESTful:英文版教程

It shows the correct usage from flask_restful import Resource, Api.

它显示了正确的用法from flask_restful import Resource, Api

回答by ChenWei

first to install flask-restful api use command:

首先安装flask-restful api使用命令:

pip install flask-restful

And import the package flask_restful,such as:

并导入包flask_restful,如:

from flask_restful import Resource,reqparse, Api