[Python] After reinstalling Python my program using locals() does not run

Discussão em 'Python' iniciado por Stack, Setembro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I've been using Python since 2021, and many programs have been working correctly since then (Python 3.10.0); however, a few days ago I installed Windows 11 and had to install Python 3.13.7. Now I have problems using locals()

    Below is an example of a function that used to work for me but no longer works:

    *def add_image():

    variable='figura10'
    locals()[variable]=PhotoImage(file='../Figuras_Ayuda/Fig10.png')
    my_text.image_create(END,image=locals()[variable])*


    I get: Exception in Tkinter callback my_text.image_create(END,image=locals()[variable]) ~~~~~~~~^^^^^^^^^^ KeyError: 'figura10'

    The correct result should be to assign locals[variable] to pyimage1.

    What did I forget when reinstalling python?

    Continue reading...

Compartilhe esta Página