Python – die besten Beiträge

Datei finden Fehler?

Hallo,

ich mache ein Programm in Python (mit Turtle), welches erkennt wo die ISS ist. Aber (obwohl es in demselben Ordner ist) findet es die Datei 'map.gif' nicht. Kann mir da jemand helfen?

Danke im voraus!

Code:

import json
import turtle
import urllib.request


url = 'http://api.open-notify.org/astros.json'
antwort = urllib.request.urlopen(url)
ergebnis = json.loads(antwort.read())


print('Personen im Weltall: ', ergebnis['number'])


personen = ergebnis['people']
#print(personen)



for p in personen:
    print(p['name'], 'in', p['craft'])


url = 'http://api.open-notify.org/iss-now.json'
antwort = urllib.request.urlopen(url)
ergebnis = json.loads(antwort.read())


standort = ergebnis['iss_position']
breitengrad = float(standort['latitude'])
längengrad = float(standort['longitude'])
print('Breitengrad: ', breitengrad)
print('Längengrad: ', längengrad)


bildschirm = turtle.Screen()
bildschirm.bgpic("map.gif")

Fehlermeldung:

File "/home/pi/Dokumente/Python programme/Standart/Wo ist die ISS?", line 29, in <module>
    bildschirm.bgpic("map.gif")
  File "/usr/lib/python3.7/turtle.py", line 1481, in bgpic
    self._bgpics[picname] = self._image(picname)
  File "/usr/lib/python3.7/turtle.py", line 479, in _image
    return TK.PhotoImage(file=filename)
  File "/usr/lib/python3.7/tkinter/__init__.py", line 3545, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "/usr/lib/python3.7/tkinter/__init__.py", line 3501, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "map.gif": no such file or directory
Python, Python 3, Tkinter

Meistgelesene Beiträge zum Thema Python