pyinstaller出现错误,不能生成exe文件

错误如下:AttributeError: 'str' object has no attribute 'items'
代码如下:
import numpy as np
import matplotlib.pyplot as plt
import xlrd
import math

path = r'C:\Users\chuchao\Desktop\test\math\data.xls'
sheetname = 'Sheet1'

workbook = xlrd.open_workbook(path)

sheet = workbook.sheet_by_name(sheetname)

#print(sheet.nrows, ' ', sheet.ncols)

data = []

for i in range(sheet.nrows):
data.append(sheet.row_values(i))

print(data)

x = np.linspace(0, math.ceil(sheet.ncols), sheet.ncols)
y = np.linspace(0, math.ceil(sheet.nrows), sheet.nrows)
X, Y = np.meshgrid(x, y)

Height = data

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

cir1 = plt.Circle((30.3 * 1000 / 38.2, 89.8 * 1000 / 38.2), radius = 10000 / 38.2) #第一个参数为圆心坐标,第二个为半径 #第三个为透明度(0-1)
cir2 = plt.Circle((66.0 * 1000 / 38.2, 84.7 * 1000 / 38.2), radius = 10000 / 38.2)
cir3 = plt.Circle((98.4 * 1000 / 38.2, 76.7 * 1000 / 38.2), radius = 10000 / 38.2)
cir4 = plt.Circle((73.7 * 1000 / 38.2, 61.0 * 1000 / 38.2), radius = 10000 / 38.2)
cir5 = plt.Circle((57.9 * 1000 / 38.2, 47.6 * 1000 / 38.2), radius = 10000 / 38.2)
cir6 = plt.Circle((86.8 * 1000 / 38.2, 22.0 * 1000 / 38.2), radius = 10000 / 38.2)
cir7 = plt.Circle((93.6 * 1000 / 38.2, 48.8 * 1000 / 38.2), radius = 10000 / 38.2)

plt.contourf(X, Y, Height, 10, alpha = 0.6, cmap = plt.cm.hot)

plt.contour(X, Y, Height, 10, colors = 'black', linewidth = 0.5)

plt.clabel(plt.contour(X, Y, Height, 10, colors = 'black', linewidth = 0.5), inline = True, fontsize = 10)

ax.add_patch(cir1)
ax.add_patch(cir2)
ax.add_patch(cir3)
ax.add_patch(cir4)
ax.add_patch(cir5)
ax.add_patch(cir6)
ax.add_patch(cir7)

plt.axis('scaled')
plt.axis('equal')

plt.show()

1个回答

缺少模块
AttributeError: 'str' object has no attribute 'items'

Maxxi_Huang
Maxxi_Huang 回复m0_37391503: 请问这个问题解决了吗?怎么弄呢?谢谢
一年多之前 回复
m0_37391503
御坂Sama 能麻烦具体说下么,缺少什么库
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐