[英]How can I solve ModuleNotFoundError: No module named 'flask_mysqldb' Error in Vs.Code?
from flask import Flask,render_template,flash,redirect,url_for,session,logging,request
from flask_mysqldb import MySQL
from wtforms import Form,StringField,TextAreaField,PasswordField,validators
from passlib.hash import sha256_crypt
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/about")
def about():
return render_template("about.html")
I use Python 3.7.3 version.我使用 Python 3.7.3 版本。 I installed flask-mysqldb.This code doesn't work and program give ModuleNotFoundError: No module named 'flask_mysqldb' Error in Vs.Code but this code work in Pycharm.
我安装了flask-mysqldb。此代码不起作用,程序给出ModuleNotFoundError:Vs.Code中没有名为'flask_mysqldb'的模块错误,但此代码在Pycharm中工作。 Pycharm's Pyton interpreter is the same with Vs.Code's.
Pycharm 的 Pyton 解释器和 Vs.Code 的一样。 How can I solve this problem?
我怎么解决这个问题?
You need to config the env
path to the VS Code.您需要配置 VS Code 的
env
路径。
List of environments VS Code found.找到的环境 VS 代码列表。
Usually, VS Code can get env from /usr/bin/
directory and from env/
directory inside your working folder.通常,VS Code 可以从
/usr/bin/
目录和工作文件夹中的env/
目录获取 env。 You can create a python environment by using python3 -m venv env
command您可以使用
python3 -m venv env
命令创建 python 环境
Select environment by clicking this inside the bottom bar( this is only appear when you open *.py
file. Select 环境,通过在底部栏中单击此按钮(仅在打开
*.py
文件时出现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.