1

How can I use the same python interpreter in development as the one in production? Interactive console in production prints:

2.7.5 (default, Jul  9 2013, 19:12:58) 
[GCC 4.4.3]

My localhost interactive console prints:

2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]

The two versions are not compatible and it is breaking my code. Specifically:

In production:

print(type(5555555555))
# <type 'long'>

On localhost:

print(type(5555555555))
# <type 'int'>

What can I do so that my local python version is always the same as the one in production?

Update: I found out that AppEngine applications run on a 32-bit architecture; while my development machine runs on a 64-bit architecture.

webo
  • 133
  • 8

1 Answers1

1

Your mac has both 32 and 64 bit versions of Python installed:

$ python
Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print(type(5555555555))
<type 'int'>
>>> ^D

$ python-32 
Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print(type(5555555555))
<type 'long'>

I just checked and the dev appserver is indeed using the 64 bit version. Not sure if I would call this a bug but worth filing a bug report with Google.

Probably the cleanest way to solve this problem is to do a separate installation of 32 bit Python and the adjust your path so that the dev appserver uses that instead.

That said, you are probably better off changing your code so that it doesn't depend the version of Python being used.

gaefan
  • 14,322
  • 16
  • 52
  • 100
  • dev appserver runs with whatever my default python is setup as. `#!/usr/bin/env python` I can't run dev_appserver.py with arch -i386 because dev_appserver.py is actually run via execfile() if we look at the source. – webo Oct 29 '14 at 17:17
  • 1
    Look up how /usr/bin/env [works](http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script). Change your default Python setup by changing your path to point to the 32 bit version of Python that you installed. – gaefan Oct 29 '14 at 17:30