Vieux Imac et Arduino

Lorsque je clique sur mon fichier pkg, j'obtiens le message suivant :
L’opération n’a pas pu s’achever. (com.apple.installer.pagecontroller erreur -1).
Je vais essayer de me débrouiller seul ...

Merci beaucoup @J-M-L
Bonne journée.

Non, pyinstaller permet de packager, avec les dépendances. Si ton application utilise une librairie X, pyinstaller fabrique un paquet contenant X.

Oui.

Ton application pourrait être copiée dans /usr/local/bin, l'endroit où, sous Linux, les applications personnelles se trouvent.
Ensuite éditer les propriétés du fichier pour le rendre exécutable, ou :
chmod +x fichier.py
Ensuite ajouter en tête de ton application :
#!/usr/bin/python3

Merci @hbachetti
Je viens tout juste de découvrir mac, je vais prendre du recul et analyser avec intérêt toutes tes remarques.
Pour l'instant je ne dispose pas assez de connaissances pour comprendre.

Merci

En l'occurrence, comme Mac OS est un Unix, tu aura à peu près les mêmes problématique sur des distributions Linux.
Si tu as plus l'habitude de Linux, tu devrais pouvoir appliquer les mêmes procédés.

Ok, on est bien d'accord : je dois lancer ma calculatrice depuis le terminal en mode administrateur. J'ai copié mon fichier py dans /usr/local/bin et j'utilise mon mot de passe pour lancer mon application.

Bon ça fonctionne mais c'est pas ce que je recherche. je veux une icône et cliquer simplement dessus. Peut-être n'avais-je pas préciser suffisamment ou pas du tout.

du coup mon code peut-être un peu foireux :expressionless: :

#!/usr/bin/python3
import tkinter as tk

calcul = ""

def center_window(w):
    eval_ = w.nametowidget('.').eval
    eval_('tk::PlaceWindow %s center' % w)

def ajout_calcul(symbol):
    global calcul
    calcul += str(symbol)
    text_resultat.delete(1.0,"end")
    text_resultat.insert(1.0, calcul)
    
def eval_calcul():
    global calcul
    try:
        calcul = str(eval(calcul))
        text_resultat.delete(1.0,"end")
        text_resultat.insert(1.0, calcul)
    except:
        effacer_ecran()
        text_resultat.insert(1.0, "erreur")

def effacer_ecran():
    global calcul
    calcul = ""
    text_resultat.delete(1.0,"end")

ecran = tk.Tk()
center_window(ecran)
ecran.title('philippe86220')
ecran.geometry("500x250")


text_resultat = tk.Text(ecran, height = 2, width = 35, font= ('arial', 24))
text_resultat.grid(columnspan = 5)

btn_1 = tk.Button(ecran, text = "1", command = lambda : ajout_calcul(1), width = 5, font= ('arial', 14))
btn_1.grid (row=2, column=1)

btn_2 = tk.Button(ecran, text = "2", command = lambda : ajout_calcul(2), width = 5, font= ('arial', 14))
btn_2.grid (row=2, column=2)

btn_3 = tk.Button(ecran, text = "3", command = lambda : ajout_calcul(3), width = 5, font= ('arial', 14))
btn_3.grid (row=2, column=3)

btn_4 = tk.Button(ecran, text = "4", command = lambda : ajout_calcul(4), width = 5, font= ('arial', 14))
btn_4.grid (row=3, column=1)

btn_5 = tk.Button(ecran, text = "5", command = lambda : ajout_calcul(5), width = 5, font= ('arial', 14))
btn_5.grid (row=3, column=2)

btn_6 = tk.Button(ecran, text = "6", command = lambda : ajout_calcul(6), width = 5, font= ('arial', 14))
btn_6.grid (row=3, column=3)

btn_7 = tk.Button(ecran, text = "7", command = lambda : ajout_calcul(7), width = 5, font= ('arial', 14))
btn_7.grid (row=4, column=1)

btn_5 = tk.Button(ecran, text = "8", command = lambda : ajout_calcul(8), width = 5, font= ('arial', 14))
btn_5.grid (row=4, column=2)

btn_5 = tk.Button(ecran, text = "9", command = lambda : ajout_calcul(9), width = 5, font= ('arial', 14))
btn_5.grid (row=4, column=3)

btn_6 = tk.Button(ecran, text = "0", command = lambda : ajout_calcul(0), width = 5, font= ('arial', 14))
btn_6.grid (row=5, column=2)

btn_ouvert = tk.Button(ecran, text = "(", command = lambda : ajout_calcul("("), width = 5, font= ('arial', 14))
btn_ouvert.grid (row=5, column=1)

btn_ferme = tk.Button(ecran, text = ")", command = lambda : ajout_calcul(")"), width = 5, font= ('arial', 14))
btn_ferme.grid (row=5, column=3)

btn_somme = tk.Button(ecran, text = "+", command = lambda : ajout_calcul("+"), width = 5, font= ('arial', 14))
btn_somme.grid (row=2, column=4)

btn_soustraction = tk.Button(ecran, text = "-", command = lambda : ajout_calcul("-"), width = 5, font= ('arial', 14))
btn_soustraction.grid (row=3, column=4)

btn_division = tk.Button(ecran, text = "/", command = lambda : ajout_calcul("/"), width = 5, font= ('arial', 14))
btn_division.grid (row=4, column=4)

btn_multiplication = tk.Button(ecran, text = "X", command = lambda : ajout_calcul("*"), width = 5, font= ('arial', 14))
btn_multiplication.grid (row=5, column=4)

btn_decimale = tk.Button(ecran, text = ".", command = lambda : ajout_calcul("."), width = 5, font= ('arial', 14))
btn_decimale.grid (row=6, column=3)

btn_egal = tk.Button(ecran, text = "=", command = eval_calcul, width = 5, font= ('arial', 14))
btn_egal.grid (row=6, column=1)

btn_effacer = tk.Button(ecran, text = "C", command = effacer_ecran, width = 5, font= ('arial', 14))
btn_effacer.grid (row=6, column=2)


ecran.mainloop()

Mais finalement je souhaite aller au bout de votre méthode mais seulement je me retrouve avec des erreurs à l'ouverture :

philippe@iMac-de-Philippe ~ % sudo /usr/local/bin/calculatrice.py

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.

2023-07-16 14:49:34.844 Python[686:16777] CoreText note: Client requested name ".SFNSMono-Regular", it will get Times-Roman rather than the intended font. All system
UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

2023-07-16 14:49:34.844 Python[686:16777] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.

2023-07-16 14:49:35.055 Python[686:16777] CoreText note: Client requested name ".SF NS Mono", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

apparement je n'ai pas la bonne version de tkinter. Pourtant le programme lancé avec l'IDLE de Python 3 fonctionne parfaitement.

Malgré les erreurs l'application se lance avec votre méthode mais bien sûr avec des différences graphiques.
En haut à droite lancement avec le terminal.
En dessous lancement du fichier avec l'IDLE de python 3.11.4

Personnellement j’utilise le python3 qui est installé en standard

En standard, vous voulez dire la version 2... pour moi ?

Les 2 sont installées pour vous

Celle de base est la première

En fait j'ai une version 2... et deux versions 3.
C'est peut-être un peu trop.

:slight_smile: oui une version 3 de trop

Merci @J-M-L
J'ai changé la première ligne de mon code en :
#!/usr/local/bin/python3
en lieu et place de :
#!/usr/bin/python3

Merci ça fonctionne très bien maintenant.

PS : J'ai pas réussi à copier mon fichier py dans la version de base.

C'est avec l'éditeur de script que je peux lancer automatiquement ma calculatrice ?

Merci.

vous voulez dire pouvoir faire un double click sur l'icon du programme python?

oui.
Après avoir fait un chmod +x calculatrice.py dans le répertoire /usr/local/bin/

j'ai tapé ce script : #!/usr/local/bin/python3/calculatrice.py dans l'éditeur de script mais lorsque j'appui sur lecture rien ne se passe ...

essayez de taper

do shell script "/usr/local/bin/python3/calculatrice.py"

En fait c'est :

do shell script "/usr/local/bin/calculatrice.py"

Je sauvegarde un script mais il m'ouvre l'éditeur et ne lance pas l'application directement.

Merci

et ça fonctionne ,

J'ai plus Catalina depuis longtemps. j'ai retrouvé un bug report
https://bugs.python.org/issue38946
et au final la personne a résolu son souci en passant à Mac OS X 11 mais ce n'est pas possible pour vous

Oui ça fonctionne avec l'éditeur de script :
j'ai une icône de mon application qui lance l'éditeur de script, je fais lecture et la calculatrice apparait.
On ne peut pas mieux faire je pense ...

Merci à tous pour votre patience.
Vous @J-M-L, @hbachetti , @fdufnews.

Très bonne soirée à vous tous.

j'avoue que je ne me souviens plus trop comment c'était sous Catalina et sur Mac je fais mes applications en Objective C (il y a longtemps) ou Swift (depuis quelques années) directement dans xCode.

Ce que vous m'avez appris vous et les autres me suffit. Mon objectif est d'acquérir les bases de Python. Je programme désormais sur ce vieux mac qui malgré son ancienneté me convient. D'ici quelques mois je m'achèterai la dernière version de l'iMac. L'OS est convivial et me plaît beaucoup.

Merci pour tout.