[issue20794] ImportError: Bad magic number in .pyc file

2014-02-27 Thread Naval Gupta
New submission from Naval Gupta: Getting below compilation error: ImportError: Bad magic number in .pyc Ran a python abc.py module which is trying to import .pyc during compilation Python Interpreter used to run: Python 2.7 Python pre-compiled file .pyc is compiled using Python

[issue20794] ImportError: Bad magic number in .pyc file

2014-02-27 Thread STINNER Victor
STINNER Victor added the comment: Can you please attach your script and give the command you are typing to reproduce the issue? -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20794

[issue20794] ImportError: Bad magic number in .pyc file

2014-02-27 Thread Peter Otten
Peter Otten added the comment: This is expected. You cannot run/import 2.6 .pyc files in python 2.7 because the file format has changed. $ echo 'print hello' tmp.py $ python2.6 -c 'import tmp' hello $ rm tmp.py $ python2.7 -c 'import tmp' Traceback (most recent call last): File string,

[issue20794] ImportError: Bad magic number in .pyc file

2014-02-27 Thread Ned Deily
Ned Deily added the comment: As Peter notes, .pyc and .pyo files are in general not compatible across Python versions. PEP 3147 was implemented in Python 3.2 to help avoid the problem you are seeing by storing .pyc/.pyo files with version-specific filenames. For Python 2, you need to be