在试图创建一个。导入matplotlib后,我收到以下错误:
回溯(最近一次调用):文件“”,第1行,在文件“C:\Users\Flo\AppData\Local\Programs\Python\Python38\Lib\site packages\matplotlib__init__.py”中,第1015行,在rcParams=rc_params()文件“C:\Users\Flo\AppData\Local\Programs\Python\Python38\Lib\site packages\matplotlib__init___.py”中,第878行,在rc_params文件中返回rc_参数(matplotlib_fname(),错误时失败)文件“C:\Users\Flo\AppData\Local\Programs\Python38\Lib\site packages\matplotlib_uinit_uuuuuuu.py”,gen\u候选者中fname的matplotlib_fname()第731行:文件“C:\Users\Flo\AppData\Local\Programs\Python38\Python38\Lib\site packages\matplotlib_uuinit\uuuuuuuuuu.py”,gen.py第728行(get_configdir(),'matplotlibrc')文件“C:\Users\Flo\AppData\Local\Programs\Python\Python38\Lib\site packages\matplotlib\uu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu(\u get\u xdg\u config\u dir())文件“C:\Users\Flo\AppData\Local\Programs\Python38\Lib\site packages\matplotlib\u init\uuuuuuuuu.py”,第562行,在\u get\u xdg\u config\u dir返回os.environment.get('xdg\u config\u HOME'))或str(Path.HOME()/“.config”)AttributeError:type对象“Path”没有属性“HOME”回溯(最近一次调用):文件中的第1行“C:\Users\Flo\AppData\Local\Programs\Python 38\Lib\site packages\matplotlib\uuuu init\uuuu.py”,第1015行,在rcParams=rc_params()文件中“C:\Users\Flo\AppData\Local\Programs\Python\Python 38\Lib\site packages\matplotlib\uu init\uu.py”,第878行,在rc_参数中从_文件返回rc_参数(matplotlib\u fname(),在_错误时失败)”C:\Users\Flo\AppData\Local\Programs\Python38\Python38\Lib\site packages\matplotlib\uuuu init\uuuuuu.py”,第731行,在gen\u候选者中的fname的matplotlib\u fname()中:文件“C:\Users\Flo\AppData\Local\Programs\Python\Python38\Lib\site packages\matplotlib\uu init\uuuu.py”,第728行,在gen\u候选者中生成os.path.join(get\u configdir(),“matplotlibrc”)文件”C:\Users\Flo\AppData\Local\Programs\Python38\Lib\site packages\matplotlib\uuuu init\uuuu.py”,第276行,在wrapper ret=func(**kwargs)文件“C:\Users\Flo\AppData\Local\Programs\Python\Python38\Lib\site packages\matplotlib\uu init\uuu.py”,第609行,在get\u configdir返回文件中C:\Users\Flo\AppData\Local\Programs\Python38\Lib\site packages\matplotlib__init__.py”,第562行,在“\u get\u xdg\u config\u dir return os.environ.get”('xdg\u config\u HOME')或str(Path.HOME()/“.config”)AttributeError:type对象“Path”没有属性“HOME”
如果需要,这是我的代码:
from PIL import Image, ImageFont, ImageDraw
import urllib.request
import win32com
from win32com.shell import shell, shellcon
from win32com.client import Dispatch
from os import mkdir, remove, path
from datetime import date, datetime
#import winshell
#-------------------------------------------------------------------------------
# Name: Modul1
# Purpose:
#
# Author: Flo
#
# Created: 31.03.2020
# Copyright: (c) Flo 2020
# Licence: <your licence>
#-------------------------------------------------------------------------------
from datetime import date, datetime
import urllib.request
import zipfile
from shutil import copyfile, rmtree
import csv
import matplotlib.pyplot as plt
import time
start = time.time()
#-------------------------------------------------------------------------------
def datumedit(index, datumls, indexhinzufügen):
ind = datumls.index(".")
if ind != index:
datumls.insert(indexhinzufügen, "0")
ind += 1
datumls[ind] = "-"
return datumls
#-------------------------------------------------------------------------------
def csvdelim(liste, max):
i = 0
while i != max:
ind = liste.index(";")
liste[ind] = "-"
i += 1
retour = liste.index(";")
return retour
#-------------------------------------------------------------------------------
def getvalues(file_dir,liste,liste2,ersetzenbis,floatconvertieren=False):
durchlauf2 = 0
keinedateninzeile = []
with open(file_dir, newline='') as file1:
anzahlreihen = sum(1 for line in file1)
with open(file_dir, newline='') as file:
reader = csv.reader(file)
next(reader)
for row in reader:
durchlauf1 = 0
uhrzeit = ""
listed = ""
reihe = list(str(row))
ind = csvdelim(reihe,ersetzenbis)
reihe[ind] = "-"
ind1 = reihe.index(";")
ind2 = ind+1
inddif = ind1-ind-1
while durchlauf1 != inddif:
listed = listed+reihe[ind2]
ind2 += 1
durchlauf1 +=1
if listed == "":
continue
if floatconvertieren == True:
if listed == "":
None
else:
liste.append(float(listed))
else:
liste.append(listed)
if durchlauf2 == anzahlreihen:
break
indexuhzt = reihe.index(" ")
uhrzeit = reihe[indexuhzt+1]+reihe[indexuhzt+2]+reihe[indexuhzt+3]+reihe[indexuhzt+4]+reihe[indexuhzt+5]
liste2.append(uhrzeit)
durchlauf2 += 1
return liste, liste2
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
def bestimmtertag(datumin,orte,namen,temppath,bilderpfad,aktuellermonat,aktuellesjar,tag,monat,jahr):
datumls = list(datumin)
temp = temppath
aus = False
#CSV Herunterladen
for e in orte:
start1 = time.time()
print(e)
xpm25 = []
xpm10 = []
ypm25 = []
ypm10 = []
xpm10d = ""
sensor = namen[e]
if aktuellermonat == monat and jahr == aktuellesjahr:
link = "https://www.madavi.de/sensor/data_csv/csv-files/%s-%s-%s/data-%s-%s-%s-%s.csv" %(jahr,monat,tag,sensor,jahr,monat,tag)
iszip = False
else:
link = "https://www.madavi.de/sensor/data_csv/%s/%s/data-%s-%s-%s.zip" %(jahr,monat,sensor,jahr,monat)
iszip = True
if iszip == True:
folderzip = "data-%s-%s-%s.zip" %(sensor,jahr,monat)
folderohnezip = "data-%s-%s-%s" %(sensor,jahr,monat)
filename = "data-%s-%s-%s-%s.csv" %(sensor,jahr,monat,tag)
mkdir(temp+"\\"+folderohnezip, 0o777)
with urllib.request.urlopen(link) as dl_file:
with open(temp+"\\"+folderzip, 'wb') as out_file:
out_file.write(dl_file.read())
with zipfile.ZipFile(temp+"\\"+folderzip, 'r') as zip_ref:
zip_ref.extractall(temp+"\\"+folderohnezip)
copyfile(temp+"\\"+folderohnezip+"\\"+filename, temp+"\\"+filename)
rmtree(temp+"\\"+folderohnezip)
remove(temp+"\\"+folderzip)
else:
filename = "data-%s-%s-%s-%s.csv" %(sensor,jahr,monat,tag)
with urllib.request.urlopen(link) as dl_file:
with open(temp+"\\"+filename, 'wb') as out_file:
out_file.write(dl_file.read())
#CSV zu Liste
getvalues(temp+"\\"+filename,ypm10,xpm10,6,True)
print("marker1")
getvalues(temp+"\\"+filename,ypm25,xpm25,7,True)
remove(temp+"\\"+filename)
#Graph
plt.style.use("dark_background")
plt.figure(dpi=600)
ax = plt.subplot()
ax.yaxis.grid(True)
print("marker2")
plt.plot(xpm10,ypm10,"r",label="PM10",linewidth=0.7)
plt.plot(xpm25,ypm25,"g",label="PM25",linewidth=0.7)
ax.legend(facecolor="#cccccc")#(211,211,211,1))
print("marker3")
ende1 = time.time()
plt.savefig(bilderpfad+"\\"+e+".png", transparent=True)
ende2 = time.time()
print("marker4")
plt.cla()
plt.close("all")
print('Einzelzeit: {:5.3f}s'.format(ende1-start1))
print('Durchlauf: {:5.3f}s'.format(ende2-start1))
#-------------------------------------------------------------------------------
#
def bildtransparent(bild):
img = Image.open(bild)
img = img.convert("RGBA")
datas = img.getdata()
newData = []
for item in datas:
if item[0] == 255 and item[1] == 255 and item[2] == 255:
newData.append((255, 255, 255, 0))
else:
newData.append(item)
img.putdata(newData)
img.save(bild, "PNG")
#
print("Feinstaubdaten auslesen \nAutor: Florian Gruber \nDatum: 25.03.2020")
namen = {"Festsaal":"esp8266-12774674","TH-Trakt":"esp8266-12775574", "Götzis":"esp8266-12775921", "Koblach":"esp8266-12776092"}
orte = ["Festsaal", "TH-Trakt", "Götzis", "Koblach"]
bilderpfad = shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, None, 0)
feinbilder = bilderpfad + "\\Feinstaub"
datumjetzt = datetime.now()
aktuellermonat = datumjetzt.strftime("%m")
aktuellesjahr = datumjetzt.strftime("%Y")
aktuellertag = datumjetzt.strftime("%d")
temp = feinbilder+"\\temp"
j = 1
zeitraum = False
größe = (1326,756)
höheobenzusatz = 0
höheuntenzusatz = 0
breitelinkszusatz = 0
breiterechtszusatz = 0
strichliste = [0,339,678,1017,1357,1696,1357+678,2375,2714]
uhrzeiten = ["00:00","03:00","06:00","09:00","12:00","15:00","18:00","21:00","24:00"]
#Ordner erstellen
try:
mkdir(feinbilder, 0o775)
print("Ordner erstellt")
except:
None
try:
mkdir(feinbilder+"\\temp", 0o777)
print("Ordner erstellt")
except:
None
##print(shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, None, 0))
##path1 = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, None, 0)+"\\Feinstaubdiagramme.lnk"
##desktop = winshell.desktop()
##target = path.abspath(__file__)
##shell = Dispatch('WScript.Shell')
##shortcut = shell.CreateShortCut(path1)
##shortcut.Targetpath = target
##shortcut.save()
##except:
## print("Fehler")
#Bilder Downloaden
while True:
datumin = "1.1.20"#input("Datum: ")
datumls = datumedit(2, list(datumin), 0)
datumls = datumedit(5, datumls, 3)
if len(datumls) == 8:
datumls.insert(-2,"2")
datumls.insert(-2,"0")
tag = datumls[0]+datumls[1]
monat = datumls[3]+datumls[4]
jahr = datumls[6]+datumls[7]+datumls[8]+datumls[9]
datum = jahr+"-"+monat+"-"+tag
try:
mkdir(feinbilder+"\\"+datum, 0o775)
print("Ordner erstellt")
except:
None
if aktuellertag == tag and aktuellermonat == monat and aktuellesjahr == jahr:
tage = 0#int(input("Anzahl Tage (0 für 24h): "))
i = 1
links = []
if tage == 0:
bzeitr = "24-Stunden"
for e in orte:
sensor = namen[e]
link = "https://www.madavi.de/sensor/images/sensor-%s-sds011-1-day.png" %sensor
bild = open(feinbilder+"\\"+e+".png", "wb")
bild.write(urllib.request.urlopen(link).read())
bild.close()
if tage > 1:
bzeitr = "7-Tage"
for e in orte:
sensor = namen[e]
link = "https://www.madavi.de/sensor/images/sensor-%s-sds011-1-week.png" %sensor
bild = open(feinbilder+"\\"+e+".png", "wb")
bild.write(urllib.request.urlopen(link).read())
bild.close()
if tage > 7:
bzeitr = "1-Monat"
for e in orte:
sensor = namen[e]
link = "https://www.madavi.de/sensor/images/sensor-%s-sds011-1-month.png" %sensor
bild = open(feinbilder+"\\"+e+".png", "wb")
bild.write(urllib.request.urlopen(link).read())
bild.close()
if tage > 31:
bzeitr = "1-Jahr"
for e in orte:
sensor = namen[e]
link = "https://www.madavi.de/sensor/images/sensor-%s-sds011-1-year.png" %sensor
bild = open(feinbilder+"\\"+e+".png", "wb")
bild.write(urllib.request.urlopen(link).read())
bild.close()
zeitraum = True
else:
bestimmtertag(datumin,orte,namen,temp,feinbilder,aktuellermonat,aktuellesjahr,tag,monat,jahr)
größenzusatz = True
#Collage erstellen
if größenzusatz == True:
größe = (7080,5600)
höheuntenzusatz = 2300
höheobenzusatz = -203
breitelinkszusatz = -80
breiterechtszusatz = 2752
collage = Image.new("RGB",größe,(0,0,0))
draw = ImageDraw.Draw(collage)
for e in orte:
if j == 1:
tup1 = (10+breitelinkszusatz,60+höheobenzusatz) # Posithtml" target="_blank">ion Einzelbild
tup2 = (189,35) #Position Text Orte
tup3 = (406,2424) #Rechteck Beginn
tup4 = (3390,2550) #Rechteck Ende
tup5 = [541,2454,541,199] # Linien erstellen Ausgangswerte
elif j == 2:
tup1 = (668+breiterechtszusatz,60+höheobenzusatz)
tup2 = (3707,35)
tup3 = (3896,2424)
tup4 = (6880,2550)
tup5 = [4031,2454,3930,199]
elif j == 3:
tup1 = (10+breitelinkszusatz,423+höheuntenzusatz)
tup2 = (189,2903)
tup3 = (406,5290)
tup4 = (3390,5416)
tup5 = [541,5320,541,3066]
elif j == 4:
tup1 = (668+breiterechtszusatz,423+höheuntenzusatz)
tup2 = (3707,2903)
tup3 = (3896,5290)
tup4 = (6880,5416)
tup5 = [4031,5320,3930,3066]
bild = Image.open(feinbilder+"\\%s.png"%e)
bild.copy()
collage.paste(bild,tup1)
bild.close()
o = 0
if größenzusatz == True:
font = ImageFont.truetype("arial.ttf", 80)
draw.rectangle((tup3, tup4), fill="black")
for f in strichliste:
if o == 9:
o = 0
draw.line((tup5[0]+f,tup5[1],tup5[0]+f,tup5[3]),fill="white",width=3)#
draw.text((tup5[0]-100+f,tup5[1]+6),uhrzeiten[o], fill="white",font=font)
o += 1
else:
font = ImageFont.truetype("arial.ttf", 70)
j += 1
#Orte schreiben
font = ImageFont.truetype("arial.ttf", 100)
draw = ImageDraw.Draw(collage)
draw.text(tup2,e,fill="white",font=font)
draw.text((10,8),datum,(0,0,0),font=font)
if zeitraum == True:
draw.text((1230,8),bzeitr,(0,0,0),font=font)
#Bild speichern
if zeitraum == True:
collage.save(feinbilder+"\\"+datum+"\\"+bzeitr+".png")
else:
collage.save(feinbilder+"\\"+datum+"\\"+datum+".png")
#Einzelbilder löschen
for e in orte:
remove(feinbilder+"\\"+e+".png")
#Bild öffnen
collage.show()
break
执行这个
卸载路径库
问题内容: 我是使用log4j软件包的新手,但看不到错误:这是一个非常简单明了的代码示例: 当我尝试编译时,出现此错误: my.package.logging.TestLogger.main(TestLogger.java:15)上的org.apache.logging.log4j.LogManager.getLogger(LogManager.java:129)处的线程“ main”中的java
如果没有找到可行的初始值设定项列表构造函数,则再次执行重载解析,其中候选函数是类T的所有构造函数,参数列表由初始值设定项列表的元素组成。 : 如果构造函数的第一个参数类型为或对某些类型可能是CV限定的的引用,并且没有其他参数,或者所有其他参数都具有默认参数,则构造函数就是初始化式列表构造函数
我正试图在谷歌地图Android API v2中获得一个带有自定义图标的标记。我刚刚更改了Google提供的一个示例。我添加了到方法中的RawMapViewDemoActivity 但我总是得到一个“IBitmapDescriptorFactory未初始化”。 在BitmapDescriptorFactory中,它说: 在使用此类中的任何方法之前,您必须执行以下操作之一以确保初始化此类: > 等待
我最近安装了适用于Windows 64位的jdk-7u11。它最初运行得很好,我使用javac和java成功地编译和执行了我的java程序。但后来,当我使用javac编译一个文件时,它会顺利进行,当我继续使用java执行该文件时,会出现以下错误: VM初始化期间出错 java/lang/NoClassDefFoundError:java/lang/Object 我该怎么办?我是jdk的新手用户,我
我是一个新的Java学生,正在编写一个程序,它由一个main方法,一个类文件,两个input.txt文件和一个output.txt文件组成。主要方法应该询问用户帐户余额和年息是多少,并从它们各自的文件中导入存款和取款信息,然后在输出文件中显示来自类文件的所有计算。我最初写这个文件是为了要求用户使用扫描仪输入所有这些信息,现在我正在尝试使用文件作为输入来让它工作……这并不是很顺利。 主要方法: }
我有以下Java代码: 但是,当我运行它时,它会抛出以下错误: 我在do之前初始化了变量。while 循环,并在 try. 中设置值。捕获循环。似乎尚未设置该变量。抱歉,如果这是一个相当基本的问题,但我似乎无法弄清楚。