Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile an app on a M1 silicon device #1511

Closed
Lukikrew opened this issue Jun 9, 2022 · 17 comments · Fixed by #2025
Closed

Compile an app on a M1 silicon device #1511

Lukikrew opened this issue Jun 9, 2022 · 17 comments · Fixed by #2025

Comments

@Lukikrew
Copy link

Lukikrew commented Jun 9, 2022

I am trying to create an app with the code:

python setup.py bidst_mac

My app uses TensorFlow, so I followed this tutorial first and it runs well before freezing.
https://www.youtube.com/watch?v=4nY5lDBXdOg

However, when I try to run the .app I receive this error:

Library not loaded: @rpath/libpython3.9.dylib Referenced from: /Users/Desktop/main/build/exe.macosx-11.0-arm64-3.9/app Reason: tried: '/usr/local/lib/libpython3.9.dylib'

However, it works when I place the dylibs in the usr/local/lib folder, but as soon as I remove the folder it won't start.
Shouldn't the app also run without the files after compiling? because when I move it to another Mac it won't work, since they haven't the files in their usr/local/lib

What am I missing here?

@marcelotduarte
Copy link
Owner

marcelotduarte commented Jun 9, 2022

You didn't fill in the bug issues form so I'll have to ask....
What is your setup.py?
Are you using cx_Freeze 6.11?
I hope you should use a bin_path_includes with "/usr/local/lib"

@Lukikrew
Copy link
Author

Lukikrew commented Jun 9, 2022

I am sorry, this is honestly my first issue I ever opened :)

from cx_Freeze import setup, Executable

build_options = {'packages': ["requests", "Crypto", "skimage", "potrace", "svgwrite", "scipy", "shiboken6", "PySide6", "tensorflow", "torch", "torchvision", "cv2", "PIL"],
                 "zip_exclude_packages": []}

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

exe = Executable(script = 'launch_app.py', base=base, target_name = 'app', icon = 'icons/tools-icon.icns')

setup(name='Tools',
      version = '1.6.0',
      description = 'Tools',
      options = {'build_exe': build_options},
      executables = [exe])

Using this cx freeze, since all others give me path issues with PySide6:

cx-Freeze @ git+https://github.com/marcelotduarte/cx_Freeze.git@7596026a25e64dffb9b9d88d913dd8dce0e6c5fa

@marcelotduarte
Copy link
Owner

marcelotduarte commented Jun 9, 2022

You can test with:
pip install --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
or compiling from sources:
pip install -U git+https://github.com/marcelotduarte/cx_Freeze.git@develop

This development version has a patch to solve the issue with pyside6 (#1431)

And including the bin_path_includes build_options...

@marcelotduarte
Copy link
Owner

Change build_options to:

build_options = {'packages': ["requests", "Crypto", "skimage", "potrace", "svgwrite", "scipy", "shiboken6", "PySide6", "tensorflow", "torch", "torchvision", "cv2", "PIL"],
                 "zip_exclude_packages": [],
                 "bin_path_includes": "/usr/local/lib"
}

@Lukikrew
Copy link
Author

Lukikrew commented Jun 9, 2022

@marcelotduarte Okay I was able to use now the newest pip install you mentioned above.

I also added the bin_path_includes, but unfortunately there wasn't any difference. Still, when I remove the lib folder, it won't run anymore.

I noticed that when I run it with the new pips I get an code signing issue as well. Also the missing lib issue is still there.
So I switched back to the other pip, since there's no codesign error, but the missing lib issue isn't fixable for me.

@marcelotduarte
Copy link
Owner

Can you test with v 6.11 and/or the latest development version?
For binary wheels?
pip install --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze
or compiling from sources:
pip install -U git+https://github.com/marcelotduarte/cx_Freeze.git@develop

@marcelotduarte
Copy link
Owner

marcelotduarte commented Oct 13, 2022

cx_Freeze 6.12.0 has just been released.
Can you check if this has been resolved?

@jczic
Copy link

jczic commented Oct 17, 2022

Hi @marcelotduarte, @Lukikrew, I've the same problem with macOS 12.4 (M1).
Just for information, it does exactly the same thing with py2app and pyInstaller on another recent mac (M1) with python 3.9 or 3.10.
And this, even if the application is signed correctly with a real Apple certificate.
Same with cx_Freeze '6.12.0'.

@trylaarsdam
Copy link

trylaarsdam commented Nov 24, 2022

I'm having this issue as well on my M1 air running Ventura. cx_Freeze 6.13.1, Python 3.9.6

Running the build with rosetta using arch -x86__64 python3 setup.py build still yields a similar error:

error: [Errno 2] No such file or directory: '/usr/local/opt/libiodbc/lib/libiodbc.2.dylib'

@marcelotduarte
Copy link
Owner

Try to install using:
pip install --no-binary=cx_Freeze cx_Freeze

@hafley
Copy link

hafley commented Dec 30, 2022

casey@mac-monterey % cxfreeze -c main.py --target-dir dist

copying /usr/local/opt/libiodbc/lib/libiodbc.2.dylib -> /Users/casey/Desktop/dist/libiodbc.2.dylib
Traceback (most recent call last):
File "/Users/casey/Library/Python/3.9/bin/cxfreeze", line 8, in
sys.exit(main())
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/cli.py", line 370, in main
freezer.Freeze()
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 633, in Freeze
self._write_modules(library_zip, finder)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 520, in _write_modules
self._copy_package_data(module, target_package_dir)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 214, in _copy_package_data
copy_tree(source_dir, target_dir, excludes)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 200, in copy_tree
copy_tree(source_subdir, target, excludes_subdir)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 200, in copy_tree
copy_tree(source_subdir, target, excludes_subdir)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 200, in copy_tree
copy_tree(source_subdir, target, excludes_subdir)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 202, in copy_tree
self._copy_file(source, target, copy_dependent_files=True)
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 176, in _copy_file
self._post_copy_hook(
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 979, in _post_copy_hook
self._copy_file_recursion(
File "/Users/casey/Library/Python/3.9/lib/python/site-packages/cx_Freeze/freezer.py", line 1017, in _copy_file_recursion
shutil.copyfile(source, target)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/opt/libiodbc/lib/libiodbc.2.dylib'

@marcelotduarte
Copy link
Owner

@hafley See #1671
Uninstall cx_Freeze:
pip uninstall -y cx_Freeze
And install with:
pip install --no-binary=cx_Freeze cx_Freeze

@gsainsbury86
Copy link

After following the instructions here, I can confirm that the issue still exists on my M1 Mac. I installed libiodbc using homebrew as well and still no luck.

@scissor
Copy link

scissor commented Mar 2, 2023

@gsainsbury86

After following the instructions here, I can confirm that the issue still exists on my M1 Mac. I installed libiodbc using homebrew as well and still no luck.

I use rosetta with x86 homebrew to install libiodbc, it works for me.

@OptimusGREEN
Copy link

@gsainsbury86

After following the instructions here, I can confirm that the issue still exists on my M1 Mac. I installed libiodbc using homebrew as well and still no luck.

I use rosetta with x86 homebrew to install libiodbc, it works for me.

Any tips on how to do this?

@marcelotduarte
Copy link
Owner

I believe patch #1942 resolves this issue. Please test and give me feedback. See more: #1548 (comment)

@marcelotduarte
Copy link
Owner

Release 6.15.3 is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants