I’m trying to use CPLEX within Python on Mac OS 10.7.5. CPLEX appears to only support a 32 bit python. I’m using this in a python shell to check if it’s 32 bit:
import sys,platform; print platform.architecture()[0], sys.maxsize > 2**32
I’ve tried these 2 commands as suggested in man 1 python, but neither seem to force 32 bit:
export VERSIONER_PYTHON_PREFER_32_BIT=yes
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
The only thing that seems to work is this:
arch -i386 python
However, if I run a script using arch which calls other scripts, they all seem to start up in 64 bit mode. Is there another system wide variable to force it into 32 bit mode?
You can use the
lipocommand to create a copy of the Python interpreter with onlyi386support.Then arrange for your existing scripts to call
python-i386, or (if they use the/usr/bin/envtrick) rename it topythonand put it in a directory that’s in yourPATHsomewhere before/usr/bin.Note that looking at
platform.architecture()or evenplatform.machine()doesn’t actually tell you if the current process is 32-bit or 64-bit. Those always give 64-bit answers for me. But when I check in Activity Monitor, I can see that my stripped binary is not marked “(64-bit)”, while other processes are.