type_cc 2017-10-21 15:47 采纳率: 33.3%
浏览 3824

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条回答 默认 最新

  • threenewbee 2017-10-22 13:54
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 写uniapp时遇到的问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流