如何强制我的代码在虚拟环境中使用32位Python?

时间:2014-08-22 20:29:35

标签: python

标题几乎说明了一切。 Python 2.7.8,OSX 10.8.5已经尝试过(单独)所有方法:

How do I force Python to be 32-bit on Snow Leopard and other 32-bit/64-bit questions

arch -i386 /usr/local/bin/python

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

export VERSIONER_PYTHON_PREFER_32_BIT=yes

当我跳进解释器并运行import platform; platform.architecture()时,我仍然得到

('64bit', '') 对于每一个。

sys.maxsize > 2**32返回True

1 个答案:

答案 0 :(得分:1)

platform.architecture()在OSX上不可靠,为了确保您仍在运行64位而不是32位,您应该运行sys.maxsize > 2**32

https://docs.python.org/2/library/platform.html#platform.architecture