Search code examples
pythonmacoscx-freezedylib

Location of Python dylib from python itself in Mac


We can get the location of python27.dll in Windows from link location of python27.dll from python itself

However, how to get the location of python-build-in dylib in Mac with python itself?


The system default python dylib is

/System/Library/Frameworks/Python.framework/Versions/2.7/Python

Homebrew-build python dylib is :

/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/Python

We use cx_Freeze to build standalone binary and need to know which python dylib is the right one.


Solution

  • Use subprocess to run the command below ($ExecuableFilePath$ can be /usr/local/bin/python or execuable file created from cx_Freeze):

    otool -L $ExecuableFilePath$
    

    The output path of the Python lib is the right location.