ModulenotFoundError:No模块名为' pandas'在Visual Studio代码中
我正在尝试运行一个可以上传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代码上运行此错误时,此错误会弹出: modulenotfounderror:no模块名为“ pandas'
这是VS代码问题选项卡中的错误消息::导入“熊猫”无法从source pylance(reportmissingmodulesource)
我尝试过多种解决方案,我将在这里列出它们:
- “ pip install astell wheel'
- “ pip install install pand pandas - upgrade - upgrade”
- 重新启动vs代码
- 卸载和重新安装和重新安装和重新安装。 Python在我的设备中
什么都没有。所有显示“需求已经满足”。 如果有帮助,我的解释器是Python 3.10.4 64位。 帮助!提前致谢!
I'm trying to run a flask code that would upload an excel file and display its contents on my local browser. This is the code :
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)
Now when I run this on VS Code, this error pops up : ModuleNotFoundError: No module named 'pandas'
This is the error message in the problem tab of VS Code : Import "pandas" could not be resolved from sourcePylance(reportMissingModuleSource)
I've tried multiple solutions, I'll list them here :
- "pip install wheel"
- "pip install pandas --upgrade"
- Restarting VS Code
- Uninstalling and reinstalling python in my device
Nothing has worked. All show "Requirement already satisfied".
My interpreter is Python 3.10.4 64-bit, if it helps.
HELP! Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过卸载和重新安装熊猫? 如果您在VENV中工作,也可以尝试
,请确保您要安装到VENV,而不仅仅是系统库。
Have you tried uninstalling and reinstalling pandas? You could also try
If you're working in a venv, make sure you're installing to the venv and not just to the system library.
您提到的是解释器(Python 3.10.4 64位)。这让我觉得您不是使用VENV口译员,而是使用全球口译员。您确定在VSCODE中使用了正确的解释器吗?
您提到您正在安装到VENV。但是也许解释器未在VScode中设置为。
检查一下以选择解释器: https:https:// code。 VisualStudio.com/docs/python/environments#_work-with-python-interpreters
You mentioned the interpreter is (Python 3.10.4 64-bit). This makes me feel you are not using the venv interpreter but the global one. Are you sure you are using the correct interpreter in vscode?
You mentioned you are installing to a venv. But maybe the interpreter is not set to that in vscode.
Check this out to select the interpreter: https://code.visualstudio.com/docs/python/environments#_work-with-python-interpreters
您是否正确地导入大熊猫的道路?
错误消息在VS代码的问题选项卡中:导入“ PANDAS”无法从sourcepylance(reportMissingModulesource)解决,
这意味着VSCODE无法识别它。
您可以在设置中添加pandas'path。
Have you imported the path of pandas correctly?
error message in the problem tab of VS Code : Import "pandas" could not be resolved from sourcePylance(reportMissingModuleSource)
This means vscode doesn't recognize it.
You could add pandas'path in the settings manually.