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.
Related
I want to import fortran files to my python script by using f2py.
For that I compile them via
f2py -c -m my_lib *.f
which produces the file "my_lib.cpython-38-darwin.so" which I import to my script by
import my_lib.
On my Intel-based Macbook that works well. However, running the script on an M1 machine yields the following error:
ImportError: dlopen(./my_lib.cpython-38-darwin.so, 0x0002): tried: './my_lib.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/my_lib.cpython-38-darwin.so' (no such file), '/usr/lib/my_lib.cpython-38-darwin.so' (no such file)
Same happens when I start my terminal in Rosetta mode.
Any idea how to solve this issue?
I don't know if you could solve the problem but I found a solution to solve it on my Mac.
Running f2py on my Mac caused the same error.
After some time of searching for reasons I tried to use another Python Environment (based on another Base Interpreter).
Till changing I used an Anaconda Environment.
I think the error could be caused by an interpreter that's not running natively on the M1 chip. The compiled Fortran code must run natively on the Mac. So probably there could be problems in compatibility.
Now I'm using the Interpreter given by the "Developer Command Line Tools" (in this case Python 3.8) to compile the source code and to build the .so file.
I also use this Base Interpreter to run my script that has to include the Fortran package.
By doing so I was able to make it work on my Mac.
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.
Is there now an easy protocol to build a .exe from python 3.5+, using modules pyqtgraph, qt5, theano, pymc3, numpy, scipy, os and sys, and opening a simple GUI stored in a '.ui' file ? I lost hours and eventually failed to make one (for w7-64 bits). Help !
preliminary failure with py2exe: I first install py2exe for python 3 but it turns out this is not compatible with my python 3.6 yet, so I downgraded to python 3.5… to get a bunch of errors. Then I went to forums and tried the proposed cures but failed (I’m uneasy with windows), the alternative being to downgrade to python 3.4… So I downgraded to python 3.4 to get an error concerning a missing ‘msvcr100.dll’ that I tried to install following instructions on forums but by default I don’t have the permission to modify system directories… When I eventually had this permission it turns out the ‘regsvr32’ command fails (isn’t this for 32 bits ? but there is no ‘regsvr64’…). Following episodes are described below.
update august 23, 2017, 1pm:
I also tried pyinstaller as advised but it failed (see my related question build a .exe for Windows from a python 3 script importing theano with pyinstaller)
I also tried cx_freeze but it failed (see my related question build a .exe for Windows from a python 3 script)
I also tried pynsist but it fails (same link than above)
what's next ?
update september, 2, 2pm:
I eventually managed to build a .exe with pyinstaller after many episodes.
Unfortunately I failed to deal with the ‘theano’ module (that is required in my case by the ‘pymc3’ module) and I had to modify the .py files and give up part of the application. Could anyone help me building a .exe for windows 7+, with the ‘theano’ module ?
see build a .exe for Windows from a python 3 script importing theano with pyinstaller
Pyinstaller Works with Python 3.5 and it is working even for packages like tensor-flow, scipy , etc (The packages I worked with)
py -3.5 pip install pyinstaller
then go the C:\Users\user\AppData\Local\Programs\Python\Python35\Scripts
and run the command
pyinstaller <code .py file along with directory> --onefile
--onefile : is for compressing the build and get a single file as output
I would suggest pyinstaller see http://www.pyinstaller.org/
The pyinstaller already supports 3.5
The development version supports 3.6
It is better to use spec file to import other hidden libraries. I listed all Sklearn libraries and add them to spec file as a hiddenimports, you can add libraries you used in your project.
I am trying to use Nuitka to compile a simple zeroMQ example and am having problems. I have used the following command to compile:
nuitka --standalone --portable --remove-output --recurse-all --python-version=3.4 testclient.py
and I get the following compile time warning:
Nuitka:WARNING:testclient.py:1: Cannot find 'zmq' as absolute import.
When I run the exe the run time error is:
ImportError: No module named 'zmq'
Am I doing something wrong or is there an incompatibility with nuitka and zmq? ( The testclient.py works fine in the interpreter. )
Can anyone help with fixing this? ( I post this here instead of emailing the Nuitka author directly so others can learn from my difficulties aswell )
Using Ubuntu 14.04 and Python3.4.
Edit: Having similar problems using Windows 7 with Anaconda Python 3.4.
Extract egg packages so that plain .py files are accessible.
You can do it by adding
[easy_install]
zip_ok = false
to your ~/.pydistutils
and reinstalling dependencies.
For some reason nuitka 0.5.14.3 does not like compressed .egg files
For a schoolproject I need to make use of the aubio library. However, I have a problem compiling it for Windows.
I downloaded the latest source from his git (0.4.0 alpha). Then I compiled it using Cygwin, using the --with-target-platform=win32 to cross-compile it for Windows. It uses waf by the way.
This works without any errors.
Next step is copying the compiled file (libaubio.dll.a) to MinGW library folder. Then I want to compile the Python wrapper for the module, but it shows up the ld.exe cannot find -laubio error. Renaming the libaubio.dll.a to libaubio.a resolves this and compiling succeeds succesfully.
Installing it into the Python folder works perfectly too. But here starts the problem. When trying to import aubio, I get this error: ImportError: DLL load failed: Invalid access to memory location.
I have no clue on how to solve this problem. Can anybody help? Or explain the error to me?
Thanks in advance!
Xander
PS. It compiles perfectly on both OSX and Ubuntu.
Well, this may not be the right solution for you, just a hint. ImportError: DLL load failed: Invalid access to memory location. I encountered the same error when trying to make my own extension of Python programmed in C. Platform: Windows 32bits.
It was a real pain because this error appeared randomly in interactive as well as in non-interactive mode in all Python environments (Spyder, Notebook, plain console...). I compiled my code using MinGW and Python's distutils (command python setup.py install). The compilation gave no warnings or errors and produced pyd file to the correct directory. But when trying to import this module import example pro my Python code it irregularly crashed (usually only one out of five attempts to import the module succeeded).
Strange was that on another computer it worked just fine... Well, finally I found workaround - I downloaded a newer version of MinGW (before I had used the version that comes packed in Qt SDK distribution) and compiled the module again. Then it worked with no more crashes. However I did not find any systematic solution or explanation. So I might have something to do with the compiler (maybe absence of its DLLs? I do not know exactly) that was used to generate the pyd file.