I'm currently learning Python (Flask) and would like to setup a tiny REST API for an HelloWorld. I choose flask_restful to implement the API and followed the tutorial on their website.
The problem is, that PyCharm is telling me the ImportError:
No module named flask_restful
although I implemented the library via the project interpreter in my VirtualEnvironment.
This is my code:
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)
Does anybody know the trick, to use flask_restful correctly?
INFO 2016-11-26 13:25:04,657 admin_server.py:116] Starting admin server at: http://localhost:8000
ERROR 2016-11-26 13:25:07,163 wsgi.py:263]
Traceback (most recent call last):
File "/Users/GamerXX/Documents/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/GamerXX/Documents/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Users/GamerXX/Documents/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/GamerXX/PycharmProjects/PartyMate/main.py", line 3, in <module>
from flask_restful import Resource, Api
ImportError: No module named flask_restful
INFO 2016-11-26 13:25:07,169 module.py:788] default: "GET / HTTP/1.1" 500 -