I am trying to learn the basics of apis and flask restful, and was trying to run the minimal api in the flask documentation.
I installed flask and flask-restful into the scripts folder in the virtual environment using command prompt, and my ide picked up that these modules are installed.
However, having saved the script, when I try to run the python file in command prompt as an http server, it comes back with the following error:- ModuleNotFoundError: No module named 'flask_restful'
As far as I can tell, the module is definitely actually there (since py-charm makes it pretty clear if a module referred to in the code is not actually installed).
So two questions - what is going on? And more importantly, how do I fix it?
(PS - the above is with respect to windows command prompt)
My code for reference from flask import Flask from flask_restful import Resource, Api
app = Flask(name) api = Api(app)
class HelloWorld(Resource): def get(self): return {'hello':'world'}
api.add_resource(HelloWorld,'/')
if name == 'main': app.run(debug=True)
CodePudding user response:
Do you have flask-restful
installed on your system? If not just use pip for installation, and type in your command prompt this command: pip install flask-restful