Akhil Seeramsetty
Akhil Seeramsetty

Reputation: 83

ImportError: No module named 'flask_cors'

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

enter image description here Thankyou

Upvotes: 2

Views: 18223

Answers (2)

Orhan Celik
Orhan Celik

Reputation: 1575

If you're running flask from a conda environment, install flask_cors with conda:

conda install flask_cors

Upvotes: 0

Molly Wang-MSFT
Molly Wang-MSFT

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.

Please have a try. enter image description here

Upvotes: 9

Related Questions