'cx_freeze MacOs : Bad Python Path

I got a problem trying to compile any python program with cx_freeze on Mac. For now the program i'm trying to get an executable is the following:

print('Hello World')

I use the following setup.py file

from cx_Freeze import setup, Executable
import sys


base = 'Win32GUI' if sys.platform=='win32' else None

executables = [ Executable('test.py', base=base) ]

setup(name='test',
      version = '1.0',
      description = 'test',
      executables = executables)

When I run python setup.py install everything goes well. When I open the program on my computer everything is working fine.

But on another computer I always end Up with the error

MacBook-Air-de-XXX:~ toto$ /Users/toto/PycharmProjects/test/build/exe.macosx-10.12-x86_64-3.6/test ; exit;
dyld: Library not loaded: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/Python
  Referenced from: /Users/toto/PycharmProjects/test/build/exe.macosx-10.12-x86_64-3.6/test
  Reason: image not found
Abort trap: 6
logout

I end up with the same error if I uninstall python from my computer. So I assume this is because the executable 'test' isn't looking for the python executable in the exe.macosx-10.12-x86_64-3.6 folder (which is present) but in the local Python executable.

So I have to know how to change that, but regarding the cx_freeze doc there is no solution ...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source