Echanges autour d'EduPython.
Vous n'êtes pas identifié(e).
Bonjour, je suis entrain de fais un programme avec PIL en python mais quand je veux ouvrir mon image avec la fonction .open, il me renvois qu'il ne trouve pas la photo.
Voici mon programme :
from PIL import Image im1=Image.open("photo.jpg") L,H=im1.size im2=Image.new("RGB",(L*2+10,H)) for x in range(L): for y in range(H): p=im1.getpixel((x,y)) im2.putpixel((x,y),p) im2.show()
Voici se que la console me renvois :
$ C:/Users/macha/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/Users/macha/OneDrive/Bureau/truc/symetrie.py
Traceback (most recent call last):
File "c:\Users\macha\OneDrive\Bureau\truc\symetrie.py", line 4, in <module>
im1=Image.open("photo.jpg")
File "C:\Users\macha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\PIL\Image.py", line 3092, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'photo.jpg'
Hors ligne
Bonsoir,
1) Avez-vous donné un nom à votre script Python ?
2) L'image se trouve-t-elle dans le même dossier que votre programme ?
Bonne soirée,
V. Maille
Hors ligne
Oui, mon script à bien un nom et mon image se trouve bien dans le même dossier.
Hors ligne
En regardant le message de plus près, je pense qu'il y a un conflit d'installation avec un autre logiciel Python type Anaconda, car le chemin de PIL est C:\Users\macha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\PIL\Image.py qui n'est pas celui d'EduPython....
Hors ligne
Ceci étant dit, essayez quand même d'ajouter en début de script :
import os os.path.exists('testfile.txt')
Hors ligne