metachris / py2app

Fork of the original py2app from https://bitbucket.org/ronaldoussoren/py2app
https://pythonhosted.org/py2app/
Other
73 stars 17 forks source link

python3.4 setup.py py2app App Run Error #5

Open Hbethray05 opened 6 years ago

Hbethray05 commented 6 years ago

I am using py2app to build applications for data processing. I used Anaconda python3.4. I had everything working great and could build a working application, but now I have done something to mess things up. I was attempting to build an application that imported MDSplus (data storage that works with python). In my attempts to make this happen I messed up my py2app. I can run ALL of my scripts as GUIs from the terminal window, making me thing wxpython is working just fine:

$ pythonw test_gui.py

They all work great, and even the build finishes like expected::

$ python setup.py py2app


OUTPUT . . .

Done!


BUT, when I click on the app to open it (I open from Package Contents to see errors in the terminal window) I get the following error.


ERROR ImportError: dlopen(/Users/hyq/Desktop/dist/test_gui.app/Contents/Resources/lib/python3.4/lib-dynload/wx/_core.so, 2): Symbol not found: _iconv Referenced from: /Users/hyq/Desktop/dist/test_gui.app/Contents/MacOS/../Frameworks/libwx_baseu-3.0.0.4.0.dylib Expected in: /Users/hyq/Desktop/dist/test_gui.app/Contents/MacOS/../Frameworks/libiconv.2.dylib


I have attempted to replicate this error by writing a c++ filer::


C++ Code

include

include

using namespace std;

int main(void){

void *hndl = dlopen("Users/hyq/Desktop/test_gui.app/Contents/Resources/lib/python3.4/lib-dynload/wx/_core.so", 2);

if (!hndl)
{
   printf("The error is %s", dlerror());
}

}


OUTPUT The error is dlopen(Users/hyq/Desktop/test_gui.app/Contents/Resources/lib/python3.4/lib-dynload/wx/_core.so, 2): image not found


I understand that something in the shared object is not being linked correctly or a library is not being loaded correctly to the app. I am very new to working with .so, so any help would be much appreciated.

Hbethray05 commented 6 years ago

So I have found a work around. The issue is that py2app does not know where my wxpython is installed, my guess is that it is due to me having a python install from anaconda. The fix is super simple and for anyone else having this issue, just copy your wx folder wherever it was installed into the Package Contents of your app. Now the app can properly load all the libraries and shared objects.


Example (IF MY APP WAS ON THE DESKTOP) sudo cp -r /path/to/python_version/wx_folder /User/usr/Desktop/test_app.app/Contents/Resources/lib/python3.4/lib-dynload/


Now double click your app and open. This will work.