logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).

#1 22-01-2015 20:26:20

tot94
Membre
Distrib. : Gnome 3.4.2
Noyau : Linux 3.2.0-4-686-pae
Inscription : 15-01-2015

[RÉSOLU]Problème lancement script python

Bojour,

J'ai un problème quand je veux lancer un script en python.

Je fais :

root@debian:/home/gueg# chmod 755 ./arppoison.py
root@debian:/home/gueg# ./arppoison.py
  File "./arppoison.py", line 10
SyntaxError: Non-ASCII character '\xe2' in file ./arppoison.py on line 10, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Pourtant j'en ai fait un exécutable et python est bien présent ma machine ..

root@debian:/home/gueg# ls /usr/bin | grep 'python'
dh_python2
python
python2
python2.6
python2.7

Comment faire pour exécuter mon script ?

Merci

Dernière modification par tot94 (28-01-2015 21:05:02)

Hors ligne

#2 22-01-2015 20:49:23

sogal
Black Metal Modo
Lieu : Nord Isère
Distrib. : openSUSE Leap 42.3
Noyau : Linux 4.4.76
(G)UI : GNOME
Inscription : 09-05-2013
Site Web

Re : [RÉSOLU]Problème lancement script python

Salut,
Tu es allé voir sur la page web dont l'URL est présente dans le message d'erreur?
Visiblement, il n'y a pas de codage déclaré, ce qui est souvent nécessaire.
Essaye en ajoutant la ligne suivante:

-*- coding: utf-8 -*-


après la ligne SheBang.


1485418338.png Hello IT ! Have you tried turning it off and on again ?

Hors ligne

#3 22-01-2015 20:52:44

tot94
Membre
Distrib. : Gnome 3.4.2
Noyau : Linux 3.2.0-4-686-pae
Inscription : 15-01-2015

Re : [RÉSOLU]Problème lancement script python

Je le met au début ou à la fin du code ?
Ici c'est le début..


#!/usr/bin/env python
#
# Execute with sudo python arppoison.py
#
#
from scapy.all import *
import time
 



Merci

Dernière modification par tot94 (22-01-2015 22:55:34)

Hors ligne

#4 23-01-2015 08:28:31

sogal
Black Metal Modo
Lieu : Nord Isère
Distrib. : openSUSE Leap 42.3
Noyau : Linux 4.4.76
(G)UI : GNOME
Inscription : 09-05-2013
Site Web

Re : [RÉSOLU]Problème lancement script python

#! = ligne Shebang
Donc tu dois spécifier l'encodage juste après, comme suit:

#!/usr/bin/env python
# -*- coding: utf-8 -*-


1485418338.png Hello IT ! Have you tried turning it off and on again ?

Hors ligne

#5 28-01-2015 21:04:44

tot94
Membre
Distrib. : Gnome 3.4.2
Noyau : Linux 3.2.0-4-686-pae
Inscription : 15-01-2015

Re : [RÉSOLU]Problème lancement script python

Merci, j'ai trouvé smile

Hors ligne

Pied de page des forums