ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
342 stars 36 forks source link

libffi.8.dylib and @rpath #472

Open nuffsaz opened 1 year ago

nuffsaz commented 1 year ago

I have been trying to produce a package using py2app. I can produce a package that runs using the -A option, but when I try it without the -A option (to produce an app that will hopefully run on another computer) I get the following error when I try to run the app:

ImportError: dlopen(/Users/dch1amk/Desktop/simpleNMR_backup_231122/dist/simpleNMR_test1.app/Contents/Resources/lib/python3.10/lib-dynload/_ctypes.so, 2): Library not loaded: @rpath/libffi.8.dylib Referenced from: /Users/dch1amk/Desktop/simpleNMR_backup_231122/dist/simpleNMR_test1.app/Contents/Resources/lib/python3.10/lib-dynload/_ctypes.so Reason: image not found

I am working with python3.10 installed using Anaconda on a Mac running MacOs 10.15 (Catalina). The program I am trying to package is quite long so, for testing purposes I have created a much shorter program, essentially a "hello world" program that retains all the import statements from the original program. I have attached it below. I can produce a working version if I include just the first 5 import statements, but including any of the import statements after that triggers the error.

The supposedly missing package does exist on the system in two places. The first is: /Users/dch1amk/opt/anaconda3/pkgs/libffi-3.4.2-h0d85af4_5/lib/libffi.8.dylib The second is: /Users/dch1amk/opt/anaconda3/envs/my-rdkit-env/lib/libffi.8.dylib my-rdkit-env is the environment required for the original program.

Given that there are two copies of the required file available, I am guessing that this is a problem with the handling of @rpath. Is this a known issue and, if so, is there a workaround? I could not find one in the documentation.

Thanks.

The test program is:

import sys import os import json import webbrowser from functools import partial import PyQt5 from PyQt5 import QtCore from PyQt5 import QtWidgets from PyQt5.QtCore import QUrl from PyQt5.QtCore import pyqtSlot from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QMainWindow from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QFileDialog from PyQt5.QtWidgets import QMessageBox from PyQt5.QtWidgets import QVBoxLayout from PyQt5.QtWidgets import QHBoxLayout from PyQt5.QtWidgets import QLineEdit from PyQt5.QtWidgets import QPushButton from PyQt5.QtWidgets import QSplitter from PyQt5.QtWidgets import QMenu from PyQt5.QtWidgets import QSpinBox from PyQt5.QtWidgets import QLabel from PyQt5.QtWidgets import QAction

from matplotlib.backends.backend_qt5agg import ( FigureCanvasQTAgg, NavigationToolbar2QT as NavigationToolbar, )

from rdkit import Chem

from rdkit.Chem import AllChem from rdkit.Chem import Draw

import networkx as nx

import nx_pylab

import pandas as pd

import numpy as np

from PIL import Image

import platform

from datetime import datetime

print("\nHello") print( "The current date is %s\n" % datetime.today().strftime("%B %d, %Y %H:%M:%S") )

kretep commented 1 year ago

This comment (and issue) look related: https://github.com/ronaldoussoren/py2app/issues/286#issuecomment-692597331

I had the same problem and got it working after using a non-conda version of Python. In addition, I upgraded to Python 3.10 and reinstalled pyobjc to get it working.