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

App only works on my computer and gets Launch Error elsewhere #478

Open
HNT1807 opened this issue Dec 27, 2022 · 3 comments
Open

App only works on my computer and gets Launch Error elsewhere #478

HNT1807 opened this issue Dec 27, 2022 · 3 comments

Comments

@HNT1807
Copy link

HNT1807 commented Dec 27, 2022

Hello! Thank you for your help and for your patience with me, I did try to find the answer myself by searching for many hours on the web but I'm still getting "Launch Error" when I use a different computer.

Because the app works great on my computer, I feel like the issue is related to the modules.

  1. I tried to add the modules directly inside the app once it was created but then it tells me that my app is damaged
  2. I tried using "includes" and "packages" separately and together but it still doesn't work
  3. I tried adding executable_stub = link to my .dylib python file > it says "Unknown distribution option"
  4. I'm on M1 and I'm trying to see if the app works on my other computer on Intel > It seems that my app is universal:

Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64

  • Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64
  • Mach-O 64-bit executable arm64]
    /Users/PycharmProjects/TheYouRLator/dist/TheYouRLator.app/Contents/MacOS/TheYouRLator (for architecture x86_64): Mach-O 64-bit executable x86_64
    /Users/
    /PycharmProjects/TheYouRLator/dist/TheYouRLator.app/Contents/MacOS/TheYouRLator (for architecture arm64): Mach-O 64-bit executable arm64

Here are the modules that I'm using:

import pandas as pd
import subprocess
import tkinter.filedialog as fd
import tkinter as tk
from tkinter import Button
import xlwings as xw
from pytube import YouTube
from openpyxl.utils import get_column_letter

Here is my setup.py in its current state:


from setuptools import setup

APP = ['TheYouRLator.py']
OPTIONS = {'packages': ["tkinter", "pytube", "openpyxl.utils"], 'includes': ["subprocess", "tkinter", "tkinter.filedialog", "pandas", "xlwings"]}

setup(

    app=APP,
    executable_stub = "/Library/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib",
    data_files=[],
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

UPDATE: By running it in the terminal, it says "Unable to import required dependencies: numpy". I don't even know what that is...but I made sure that I have the last version of this thing installed and it's still not working... It looks like the module Pandas is messing things up??

Traceback (most recent call last):

  File "/Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/__boot__.py", line 161, in <module>

    _run()

  File "/Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/__boot__.py", line 84, in _run

    exec(compile(source, path, "exec"), globals(), globals())

  File "/Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/TheYouRLator.py", line 3, in <module>

    import pandas as pd

  File "/Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/lib/python3.11/pandas/__init__.py", line 16, in <module>

    raise ImportError(

ImportError: Unable to import required dependencies:

numpy: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:
    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.11 from "/Users/*/Downloads/TheYouRLator 2.app/Contents/MacOS/python"

  * The NumPy version is: "1.24.1"
and make sure that they are the versions you expect.

Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/lib/python3.11/numpy/core/_multiarray_umath.cpython-311-darwin.so, 2): no suitable image found.  Did find:

    /Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/lib/python3.11/numpy/core/_multiarray_umath.cpython-311-darwin.so: mach-o, but wrong architecture

    /Users/*/Downloads/TheYouRLator 2.app/Contents/Resources/lib/python3.11/numpy/core/_multiarray_umath.cpython-311-darwin.so: mach-o, but wrong architecture

2022-12-27 15:07:42.916 TheYouRLator[47286:309345] Launch error
@ronaldoussoren
Copy link
Owner

ronaldoussoren commented Dec 28, 2022

It looks like your application is not Universal 2 after all, the numpy extension (which is a library used by pandas) is not compatible according to the end of the error message, and likely is only compatible with arm64.

That, sadly, is not easy to fix because numpy only ships single-architecture wheels.

The easiest workaround is likely to create an x86_64 app and rely on the M1's intel emulation for users with M1 systems. To do this (untested):

  • Create a virtual environment and activate it
  • Use "arch -x86_64 python -m pip install ..." to install dependencies (this should install the x86_64 wheel for numpy)
  • Use "python setup.py py2app --arch x86_64" to build the app bundle

I'm slowly working on rewriting py2app to, amongst others, make it easier to add reporting for issues like this and might add a helper project to make it possible to convert an existing single-architecture installation into a Universal 2 one for projects like numpy that only ship single-architecture wheels.

UPDATE: For subset of projects it is possible to build Universal 2 wheels yourself, but that's not easy for a lot of the more interesting projects like numpy due to their 3th-party dependencies.

@HNT1807
Copy link
Author

HNT1807 commented Dec 29, 2022

Thank you for your help!

Also, when I use Tkinter, I have to manually import the tcl8, tcl8.6, and tk8.6 lib folders in my PyCharm project otherwise py2app won't add them in the app. Is there a way to do that automatically?

@finnigami
Copy link

Did you ever find a solution? I'm having the same issue

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

No branches or pull requests

3 participants