我正在尝试运行一个烧瓶代码,该代码将上传一个 excel 文件并在我的本地浏览器上显示其内容。这是代码:
from flask import Flask,render_template,request
import os
import pandas as pd
app=Flask(__name__)
app.secret_key="123"
app.config["UPLOAD_FOLDER1"]="static/excel"
@app.route("/display",methods=['GET','POST'])
def upload():
if request.method == 'POST':
upload_file = request.files['upload_excel']
if upload_file.filename != '':
file_path = os.path.join(app.config["UPLOAD_FOLDER1"], upload_file.filename)
upload_file.save(file_path)
data=pd.read_excel(upload_file)
return render_template("ExcelFile.html",data=data.to_html(index=False).replace('<th>','<th style="text-align:center">'))
return render_template("UploadExcel.html")
if __name__=='__main__':
app.run(debug=True)
现在,当我在 VS Code 上运行它时,会弹出此错误:ModuleNotFoundError: No module named 'pandas'
这是 VS Code 的问题选项卡中的错误消息:Import "pandas" could not be resolved from sourcePylance(reportMissingModuleSource)
我尝试了多种解决方案,我将在此处列出它们:
没有任何效果。全部显示“要求已满足”。如果有帮助,我的解释器是 Python 3.10.4 64 位。帮助!提前致谢!
您提到解释器是(Python 3.10.4 64 位)。这让我觉得您使用的不是 venv 解释器,而是全局解释器。你确定你在 vscode 中使用了正确的解释器吗?
你提到你正在安装到一个venv。但也许解释器没有在 vscode 中设置。
检查此以选择解释器:https ://code.visualstudio.com/docs/python/environments#_work-with-python-interpreters
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句