Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
77 views
in Technique[技术] by (71.8m points)

python 3.x - Why I can't import Flask?

I followed the Flask instructions and I successfully installed Flask by using Command Prompt.

C:UsersDELL>py -3 -m pip install flask

C:UsersDELL>py -3 -m pip install flask Requirement already satisfied: flask in c:usersdellappdatalocalprogramspythonpython39libsite-packages (1.1.2) Requirement already satisfied: itsdangerous>=0.24 in c:usersdellappdatalocalprogramspythonpython39libsite-packages (from flask) (1.1.0) Requirement already satisfied: Jinja2>=2.10.1 in c:usersdellappdatalocalprogramspythonpython39libsite-packages (from flask) (2.11.2) Requirement already satisfied: Werkzeug>=0.15 in c:usersdellappdatalocalprogramspythonpython39libsite-packages (from flask) (1.0.1) Requirement already satisfied: click>=5.1 in c:usersdellappdatalocalprogramspythonpython39libsite-packages (from flask) (7.1.2) Requirement already satisfied: MarkupSafe>=0.23 in c:usersdellappdatalocalprogramspythonpython39libsite-packages (from Jinja2>=2.10.1->flask) (1.1.1)

However when I use PyCharm to import flask, it doesn't recognize flask.

ModuleNotFoundError: No module named 'flask'
question from:https://stackoverflow.com/questions/65917129/why-i-cant-import-flask

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The most probable problem is py command is related with python2 and flask module is installed in your python3 site-packages. So try to execute explicitly with python3 as :

python3 app.py

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...