如何在开发中使用与生产中相同的python解释器?生产中的交互式控制台打印:
2.7.5 (default, Jul 9 2013, 19:12:58)
[GCC 4.4.3]我的localhost交互式控制台打印:
2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]这两个版本不兼容,它破坏了我的代码。具体地说:
在生产中:
print(type(5555555555))
# <type 'long'>在localhost上:
print(type(5555555555))
# <type 'int'>我该怎么做才能使我的本地python版本始终与生产环境中的版本相同?
更新:我发现AppEngine应用程序运行在32位架构上;而我的开发机器运行在64位架构上。
发布于 2014-10-23 21:01:19
您的mac安装了32位和64位版本的Python:
$ 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'>我刚刚检查了一下,dev appserver确实使用的是64位版本。我不确定这是不是一个bug,但值得向Google提交一份bug报告。
也许解决这个问题的最干净的方法是单独安装32位Python,并调整您的路径,以便dev appserver使用它。
也就是说,您最好更改代码,使其不依赖于所使用的Python版本。
https://stackoverflow.com/questions/26477406
复制相似问题