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 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题