[Tutor] Error Using exec to Run Module Files

Alan Gauld alan.gauld at btinternet.com
Wed Aug 18 10:18:28 CEST 2010


<mesrod at juno.com> wrote

>>>> exec(open('script1.py').read())
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<string>", line 1
>    %!PS-Adobe-3.0
>    ^
> SyntaxError: invalid syntax
> 
> What is going on/

Looks like your script1.py file is actually a postscript file.
exec expects to see valid Python code, it can't process Postscript.

Can you run script1.py from the command line?

Or can you import it at the >>> prompt?

HTH,

Alan G.




More information about the Tutor mailing list