How to force using 64-bit python for Mac OS X?

When compiling sip with the -arch x86_64 option, I got the following error.

  prosseek: siplib smcho $ python -c 'import sip;  print sip '
 Traceback (most recent call last):
   File "", line 1, in 
 ImportError: dlopen (./ sip.so, 2): no suitable image found.  Did find:
         ./sip.so: mach-o, but wrong architecture

I found that prebuilt Mac OS X python (snow leopard) is universal and it does not get a 64-bit library. I assume that it works in 32-bit mode.

  file / usr / bin / python 
 / usr / bin / python: Mach-O universal binary with 3 architectures
 / usr / bin / python (for architecture x86_64): Mach-O 64-bit executable x86_64
 / usr / bin / python (for architecture i386): Mach-O executable i386
 / usr / bin / python (for architecture ppc7400): Mach-O executable ppc
  prosseek: siplib smcho $ file sip.so
 sip.so: Mach-O 64-bit bundle x86_64

How can I get python to work in 64 bit mode? When I run the same code in Textmate, there is no problem. So, I think Textmate should work in 64 bit mode.

Added

  • This link shows how to determine if python is 32-bit or 64-bit. And I checked that my python is 32 bit.
  • This link shows how to make 32/64-bit python. But this does not work for me.
+4
source share
2 answers

Try using arch (1) and install a specific version of Python:

arch -x86_64 /usr/bin/python2.6 

In fact, the system should choose the first suitable architecture for you. how

 $ file /usr/bin/python2.5 /usr/bin/python2.5: Mach-O universal binary with 2 architectures /usr/bin/python2.5 (for architecture i386): Mach-O executable i386 /usr/bin/python2.5 (for architecture ppc7400): Mach-O executable ppc $ file /usr/bin/python2.6 /usr/bin/python2.6: Mach-O universal binary with 3 architectures /usr/bin/python2.6 (for architecture x86_64): Mach-O 64-bit executable x86_64 /usr/bin/python2.6 (for architecture i386): Mach-O executable i386 /usr/bin/python2.6 (for architecture ppc7400): Mach-O executable ppc 

If this python somehow chooses 2.5, then you cannot use 64-bit, but if it chooses 2.6, then the x86_64 variant should be automatically selected, as indicated below. If it is the first, try to get python_select and change the version to 2.6.

+6
source

Well, be REALLY careful when you do this, it will require other things to be 64 bit as well. Suddenly, if mod_python won't work, you need to recompile apache. Then all your python modules like tkinter / tix. If you are at 10.5, like me, don’t go there, just live with 32-bit for it.

And if you do not know about http://www.macports.org/ , then remember that this is your friend. :-)

+1
source

Source: https://habr.com/ru/post/1315122/


All Articles