You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
1.4 KiB

import os
import sys
print("========================================")
print(" 调试脚本")
print("========================================")
print(f"Python版本: {sys.version}")
print(f"当前目录: {os.getcwd()}")
print()
# 检查pandas
print("检查pandas...")
try:
import pandas as pd
print(f"pandas版本: {pd.__version__}")
except ImportError as e:
print(f"pandas未安装: {e}")
exit(1)
# 检查openpyxl
print("\n检查openpyxl...")
try:
import openpyxl
print(f"openpyxl版本: {openpyxl.__version__}")
except ImportError as e:
print(f"openpyxl未安装: {e}")
exit(1)
# 检查文件
input_file = r'D:\计量经济学\计量实验资料及作业要求\计量实验资料及作业要求\图文帖子实验数据(新).xlsx'
print(f"\n检查输入文件:")
print(f"路径: {input_file}")
print(f"存在: {os.path.exists(input_file)}")
if os.path.exists(input_file):
print(f"大小: {os.path.getsize(input_file) / 1024:.2f} KB")
# 尝试读取
print("\n尝试读取文件...")
try:
df = pd.read_excel(input_file, nrows=5) # 只读前5行
print(f"成功读取 {len(df)}")
print(f"列名: {list(df.columns)}")
except Exception as e:
print(f"读取失败: {e}")
import traceback
traceback.print_exc()
print()
print("========================================")
print(" 调试完成")
print("========================================")