python findet modul nicht obwohl es installiert ist?

2 Antworten

Vom Beitragsersteller als hilfreich ausgezeichnet

Der Pfad python312 sollte für Python 3.12 sein, während Du oben python 3.11 startest.

Hast Du beide versionen installiert?


SusgUY446 
Beitragsersteller
 23.12.2023, 19:30

ja. habe beide.

Du hast offenbar mehrere Python-Versionen installiert. Schau genau: dein Programm läuft mit 3.11, pip mit 3.12.


SusgUY446 
Beitragsersteller
 23.12.2023, 19:32

habe es jetzt geändert. bekomme jetzt aber diesen fehler

PS C:\Users\admin\Desktop\imgLock> & C:/Python312/python.exe c:/Users/admin/Desktop/imgLock/main.py
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\PIL\Image.py", line 2415, in save
    format = EXTENSION[ext]
             ~~~~~~~~~^^^^^
KeyError: '.imglock'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python312\Lib\tkinter\__init__.py", line 1962, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "c:\Users\admin\Desktop\imgLock\main.py", line 40, in encrypt_image
    encrypted_image.save(encrypted_path)
  File "C:\Python312\Lib\site-packages\PIL\Image.py", line 2418, in save
    raise ValueError(msg) from e
ValueError: unknown file extension: .imglock
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\PIL\Image.py", line 2415, in save
    format = EXTENSION[ext]
             ~~~~~~~~~^^^^^
KeyError: '.imglock'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python312\Lib\tkinter\__init__.py", line 1962, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "c:\Users\admin\Desktop\imgLock\main.py", line 40, in encrypt_image
    encrypted_image.save(encrypted_path)
  File "C:\Python312\Lib\site-packages\PIL\Image.py", line 2418, in save
    raise ValueError(msg) from e
ValueError: unknown file extension: .imglock
JulianOnFire  23.12.2023, 20:26
@SusgUY446

Er erkennt ja offensichtlich .imglock nicht...

dann änder dein Dateifomat beim speichern/übergeben als png

encrypted_image.save(encrypted_path, format="PNG")
SusgUY446 
Beitragsersteller
 23.12.2023, 20:30
@JulianOnFire

Dann kann man das ja aber auf die Datei mit einem normalen Bildprogramm zugreifen

SusgUY446 
Beitragsersteller
 24.12.2023, 11:10
@JulianOnFire

Der sinn von meinem Programm ist es das man die bilder nicht mit normalen Bildprogrammen öffnen kann. Und png wird ja von windows media viewer und so unterstützt

JulianOnFire  24.12.2023, 11:28
@SusgUY446

Erstmal Frohe Weinachten! 🎅🎄

Du kannst das Bild auch als PNG speichern und als Binärdatei mit .imglock erweitern.

with open(encrypted_path + '.imglock', 'wb') as f:
    encrypted_image.save(f, format='PNG')