Pyinstaller executable fails on old OS X - python

I have a wxPython GUI packaged into an executable with Pyinstaller. It works correctly on OS X 10.13.4, but doesn't initialize on OS X 10.12.6.
This is the error output when my executable is run from the command line:
[4693] Error loading Python lib '/var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python': dlopen: dlopen(/var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python, 10): Symbol not found: _futimens
Referenced from: /var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libSystem.B.dylib
in /var/folders/9_/5d_4dfcs4lj11bdjq4twtl5w0000gp/T/_MEIYsEh11/Python
I have no idea what this error message means. I've tried googling some pieces of it, but I'm not getting any meaningful results.
I'm looking for any clue to get me going in the right direction -- what might be wrong, or how to debug. Unfortunately I don't have access to OS X 10.12.6, so I'm having to troubleshoot for a user remotely.
This is my version of Pyinstaller:
pyinstaller 3.4.dev0+g07ab024c
This seems to happen with brew-installed Python or Anaconda.

A bit late, but it has happened to me as well. After a bit of research, as per the documentation:
https://pyinstaller.readthedocs.io/en/stable/usage.html#making-mac-os-x-apps-forward-compatible
Basically you'll need to install a virtual machine with the oldest OS you'd like support (say, osx maverick, or ubuntu 16) with the complete development environment and run pyinstaller there. As of the time of writing, there seems to be no way around it.

Related

cython and pyinstaller issue

I have an odd issue with cython and pyinstaller.
My code compilation process used to work fine, then something changed on the MAC and I did some updates and now things aren't working...
Taking my code and simply using pyinstaller works fine - no errors.
Taking my code and converting to .so files with cython and running works fine - no errors.
Taking the .so files from cython and then running through pyinstaller does not work (it used to). I get the following error:
ImportError: dlopen(/var/folders/95/mfn5xj2s59jgjjch0b8f5jbw0000gn/T/_MEIhKYuUp/WWS_Server.so, 2): Symbol not found: _Py_EnterRecursiveCall
Referenced from: /var/folders/95/mfn5xj2s59jgjjch0b8f5jbw0000gn/T/_MEIhKYuUp/WWS_Server.so
Expected in: flat namespace
in /var/folders/95/mfn5xj2s59jgjjch0b8f5jbw0000gn/T/_MEIhKYuUp/WWS_Server.so
Any ideas on where to look to solve this issue?
Mac OS Darwin
Cython version 0.29.22
pyinstaller 4.2
I found the problem was that my python had been upgraded to 3.9 which was causing problems. Moving back to 3.8 (pyenv) fixed the issue.

Illegal instruction: 4 when importing python pandas

Since my Macbook with an i7 CPU is currently with AppleCare, I am now working on an older Mac mini with a core duo CPU. I simply connected the Macbook's internal disk via USB to the Mac mini.
Now back at my Python scripts, I ran into a problem which I don't fully understand and do not know how to debug. When I import pandas in Python 2.7.9, Python crashes completely and I get the error Illegal instruction: 4. After some googling I assume, that some packages are compiled for the wrong architecture. But I don't know which ones.
I installed Python, numpy and scipy with homebrew and pandas, etc. with pip into a virtual environment. My system is OS X 10.10.5.
The output of python -vc "import pandas" is very long and given here.
I tried re-installing Python, pandas, numpy, and scipy.
How can I find out which package is causing the error?
Do I need to set an architecture flag or something?
How can I fix this?
Removing the .pyc files might work too.
Since it happens right after the call to
dlopen("/usr/local/lib/python2.7/site-packages/matplotlib/_pabc.so", 2);,
you can try checking the arch type that file was built for with:
file /usr/local/lib/python2.7/site-packages/matplotlib/_pabc.so
then check the arch type of your hardward:
uname -a
If the shared object file (_pabc.so) was not built for that machine you may need to re compile/install/whatever, matplotlib or one of its dependancies.
In my recent experience, this was indeed caused by a linked library being of the wrong architecture as the module's library (as chown suggested).
In particular, a C-compiled python library as part of the python module you're importing (the _mymodule.so file in the module directory) calling a linked system library (eg. libgfortran.dylib), and there being an architecture mismatch between the two.
As aforementioned, you can check the architecture of your system with uname -a and check the arch of an offending dylib via the file /path/to/lib.dylib command.

QtCreator Python.h with Anaconda Python

Trying to embed anaconda Python into a Qt application. As a first step, I just want to get Python.h including properly.
I am running Qt4, Python 2.7.9, and OS X 10.9.
The project.pro has:
INCLUDEPATH += /home/myuser/anaconda/include/python2.7 /home/myuser/anaconda/include
LIBS += -L/home/myuser/anaconda/lib/python2.7 -lpython2.7
appended to the end.
In spite of this, I am getting the system installed python 2.7.5. This is verified by running import sys, sys.version and sys.path.
Clearly, I am missing something - a compiler flag? New to QtCreator, so any insight appreciated.

CX_Freeze Fatal Python error: Py_Initialize: Unable to get the locale encoding

I am trying to use CX_Freeze to distribute python code for multiple platforms. In windows all went well but I am stuck trying to use CX_Freeze 5 on Ubuntu 14.04 LTS with python 3.4. I am able to run CX_Freeze without error, however when I run the resulting binary I get
/Desktop/cx/cx_Freeze/samples/simple/build/exe.linux-i686-3.4$ ./hello
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)
This happens even with the "simple" example included with CX_Freeze (as well as my program) so I believe the problem has to do with my install.
I was able to get CX_Freeze to install using this https://bitbucket.org/anthony_tuininga/cx_freeze/issue/32/cant-compile-cx_freeze-in-ubuntu-1304 workaround.
I have read that CX_Freeze can have trouble finding modules imported into python in strange ways, and that the solution is to add those files manually to the setup.py file and put the files into same folder, however there is no encodings.py file in \usr\lib\python3.4 however there is a \usr\lib\python3.4\encodings folder.
I'm sure the my problem is that I have no idea what I am doing, but I followed all of the installation directions as best I could and still ran into this problem. After two days of looking I haven't found a good answer yet so I'm going to ask here. If answer is found, maybe it will help someone else as well. Thank you for any advice you can give.
Edit: Judging from the number of views this post has gotten it is not a very common problem, however I found a solution and I want to share it in the hopes that it will help someone. The solution was to use cx_Freeze 4.3.3 instead of 5. You can find version 4.3.3 here as a tar.gz file https://pypi.python.org/pypi?:action=display&name=cx_Freeze&version=4.3.3 . You then need to make the changes described in the first link in this post make it build right. This solved the issue for me on Linux, but not on OSX. Good luck!

Busted OS X Python install

So I didn't look carefully and I installed 64 bit Python2.7 on an OS X 10.5 box. This didn't work with the standard cryptic wrong-OS message "dyld: unknown required load command"
OK, fair enough
So I dragged the Python2.7 icon to the trash from Applications; then I went in with sudo and renamed the
/Library/Frameworks/Python.framework/Versions/2.7/
to
/Library/Frameworks/Python.framework/Versions/2.7BROKEN/
and installed the 32-bit Python 2.7. But I am still getting the "dyld" error. Any idea what other side effect the broken install might have had to make this possible and how I can fix it?
Problem solved by following this bug report's instructions, substituting 2.7 for 2.6 everywhere, then reinstalling.

Categories