Reputation: 83
I have installed flask_cors like so: pip install Flask-Cors pip3 install -U flask-cors, pip install -U flask-cors pip install flask-cors --upgrade
This is my code:
from flask import Flask
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app)
any answer to solve this error is appreciated
Upvotes: 2
Views: 18223
Reputation: 1575
If you're running flask from a conda environment, install flask_cors with conda:
conda install flask_cors
Upvotes: 0
Reputation: 9481
The first case:
Install the module in not current used python interpreter. Use pip show flask_cors
to check if its location is your current python interpreter\lib\site-packages.
If not, after selecting python interpreter, open a new integrated Terminal then use command to reinstall modules.
The second case:
You've installed the module successfully in current used python environment, then import module in code, but Pylance still throws the error
ImportError: No module named 'flask_cors'<ReportMissingImports>
. What you need to do is opening Command Palette and choose Reload Window, the error should go away.
Upvotes: 9