I'm following the flask-cors tutorial from the documentation here: https://pypi.python.org/pypi/Flask-Cors
but when i installed it on my raspberry pi and run my python app i'm getting this error
Traceback (most recent call last):
File "app.py", line 3, in <module>
from flask_cors import CORS, cross_origin
ImportError: No module named 'flask_cors'
here is my python script:
from flask import Flask
from Main import main
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app)
main = main()
@app.route('/turn' ,methods=['GET', 'OPTIONS'])
def index():
return main.turn()
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
I had a similar issue where after installing flask_cors it was still giving me a ModuleNotFoundError. Try this:
sudo pip3 uninstall flask_cors
sudo pip3 install Flask-Cors
It's a subtle difference but it worked for me. Even though flask_cors appears to install a package and it's written that way in python when actually importing it, the actual package name installed with pip is Flask-Cors.
I spent a day trying to resolve this. Here are my steps: First i closed my VSCODE and open it again, then run
pip uninstall flask
pip uninstall flask_cors
pip3 install flask
pipenv shell
pipenv install flask_cors
pip install pipreqs
git add .
git commit -am "New cor resolved"
git push heroku master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With