Eseguendo AquaEmacs, voglio eseguire un buffer (C-c C-c) in Python.Esegui il buffer AquaMacs che ha "da __future__ import ..."
Il buffer inizia con:
from __future__ import print_function
L'esecuzione in AquaEmacs inizia con:
import sys,imp
if'test_one_liners' in sys.modules:
imp.reload(test_one_liners)
else:
import test_one_liners
dove test_one_liners.py è il mio file. Questo dà questo errore:
SyntaxError: from __future__ imports must occur at the beginning of the file
Qualcuno sa dove e come risolvere questo problema?
Vorrei aggiungere nuovamente le informazioni per chiarire.
Creare questo buffer:
from __future__ import print_function
print("Hello")
Utilizzare File/modalità buffer Cambia/Python per renderlo Python e C-c C-c per eseguirlo; non ha bisogno di essere salvato. Il buffer viene scritto in un file temporaneo e non riesce con SyntaxError: from __future__ imports must occur at the beginning of the file
. Il traceback include un file generato che contiene un riferimento a un file temporaneo. Cosa dovrebbe accadere invece che stampa Ciao.
1. Sì, il messaggio di errore è in inglese, quindi dice "le importazioni devono essere eseguite all'inizio del file"; il singolare sarebbe una cattiva grammatica. 2. Sì, il * buffer * viene eseguito, con C-c C-c. Il nome del file è rilevante solo per mostrare che è in modalità python.La tua ipotesi è apprezzata, anche se probabilmente ha a che fare con il file exec. Aggiungerò ulteriori informazioni –