Afficher la version installé de python avec python

Fermé
xunil2003 Messages postés 766 Date d'inscription mercredi 17 novembre 2004 Statut Membre Dernière intervention 29 septembre 2024 - Modifié le 4 févr. 2021 à 19:39
yg_be Messages postés 23526 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 14 avril 2025 - 4 févr. 2021 à 21:43
Bonjour,
J'utilise python version 2.7.17.
J'ai besoin d'afficher la version de python installer

def versions():
fs_versions = Toplevel(Frame2)
Framex0 = Frame(fs_versions, borderwidth=2, relief=FLAT)
Framex0.pack(padx=10,pady=10)

Framex1 = Frame(Framex0,borderwidth=2,relief=FLAT)
Framex1.pack(padx=10,pady=10)

Framex2 = Frame(Framex0,borderwidth=2,relief=FLAT)
Framex2.pack(padx=10,pady=10)

Framex3 = Frame(Framex0,borderwidth=2,relief=FLAT)
Framex3.pack(padx=10,pady=10)

CMD1 = "python --version"
b = os.popen(CMD1).read()
print "b :", b

scrollbar = Scrollbar(Framex2)
scrollbar.pack(side=RIGHT, fill=Y)
textbox = Text(Framex2, height=30, width=100)


textbox.tag_configure('normal', font=("Times New Roman", 14, "italic"))
textbox.tag_configure('titre', font=("Times New Roman", 22, "roman", "bold", "italic"))
textbox.tag_configure('chapitre', font=("Times New Roman", 18, "roman", "bold", "underline"))
textbox.tag_configure('texte', font=("Times New Roman", 14, "roman"))
textbox.tag_configure('gras', font=("Times New Roman", 18, "roman", "bold"))

textbox.insert(INSERT, "Versions", "titre")
textbox.insert(INSERT, "\n")
textbox.insert(INSERT, "\nVersion du système", "chapitre")
textbox.insert(INSERT, "\n"+a, "texte")
textbox.insert(INSERT, "\n")
textbox.insert(INSERT, "\nVersion de Python", "chapitre")
textbox.insert(INSERT, "\n"+b, "texte")
textbox.insert(INSERT, "\n")
textbox.pack()
textbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=textbox.yview)

Button(Framex3, text=" Ok ", command=fs.destroy).grid(row=1) #.pack(padx=10,pady=10)
fs.mainloop()


la version de python ne s'affiche pas mais dans la console oui ?
Avec textbox.insert() ça ne fonctionne pas ?

Retour
a : Linux Laurent-I7-9900K 5.4.0-65-generic #73~18.04.1-Ubuntu SMP Tue Jan 19 09:02:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Python 2.7.17
b :


Comment puis-je faire ?
Merci d'avance pour vos conseils et aides.
Configuration: Linux / Firefox 85.0
A voir également:

1 réponse

yg_be Messages postés 23526 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 14 avril 2025 Ambassadeur 1 577
4 févr. 2021 à 21:43
bonjour,
exemple:
import sys
versionpython=sys.version
print(versionpython)
0