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 有卷积神经网络识别害虫的项目吗
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)
  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件