0

I built a tool in python 2.7.5 and I compiled it with python -m compileall

When I tried to use it on the destination plateforme (python 2.6.6) I got that annoying "Magic Number" error.

I already read a bunch of things about that error and I think I understand whats happening...

Then my question is : Is there a way to specify the "target platform" when I compile the .py files or should I downgrade my current version of python to match the "production" one ?

Patrick Ferreira
  • 1,983
  • 1
  • 15
  • 31

1 Answers1

2

You cannot cross-compile for other Python versions, no.

Just install Python 2.6 next to Python 2.7 and use compileall with that to produce your bytecode files instead. You can install multiple versions of Python quite painlessly.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343