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
No module named flask.ext.restful
提问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
回答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,
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