Embendding Python 3.4 into MacOS app - macos

I'm trying to get a Python 3.4 interpreter into my app without to distribute python framework.
I'm linking with the libpython3.4.a (which appear to have dependency on Python.framework/versions/3.4/Python), but as guessed, it need python framework.
Does someone experienced this issue ?
Logically,i should be able to link statically (real static) and just distribute the python34.zip modules, right ?
Thanks for you help.
EDIT:
Finally i downloaded the Python 3.4 sources and build a static version.
Now i don't have dependency issue.
So i include the python3.4.zip near my executable.
But now, when starting the application i have this error:
"Fatal Python error: Py_Initialize: unable to load the file system codec"
So, i set Py_SetProgramName() to my binary and Py_SetPath(zippath) before the Py_Initialize().
But i still have the "ImportError: No module named 'encodings'" issue.
I also have tested with a simple folder instead of a zip.

Related

runtime error ‘symbol not found in flat namespace’ on macOS 12 but not macOS 10.15, with both Xcode and CMake builds

I have problems building an executable file for a simple disease-transmission model implemented in C++, using cmake under macOS Monterey (v12.6.1). When I build the executable file, I obtain the following error when I try running it:
dyld[5281]: symbol not found in flat namespace (_cblas_caxpy) Abort trap: 6
The problem persists when I try to use XCode (v14.0.1) instead, resulting in the same error message.
Interestingly, my friend is able to build (& run) the executable file under macOS v10.15.7 without any problems.
Does anybody know what is going on here and how this issue can be resolved? The C++ project is publicly available on GitHub: https://github.com/AnnaMariaL/DengueSim
Any help would be very much appreciated.
Thanks!
Anna
tried: build an executable file with cmake, and Xcode under MacOS v12.16.1
expected: executable file
the program runs fine when launched under Xcode itself, but if I try to run the built executable from Xcode on the command line, that fails with the same error as for the CMake executable. So Xcode itself is, somehow, magically able to get this linker issue to resolve.
Your title/post is very confusing, however the issue isn't with cmake. It's with your cblas library and/or your linker. Look at the bug closely:
dyld[5281]: symbol not found in flat namespace (_cblas_caxpy) Abort trap: 6
Your linker is telling you that it can't find a function (symbol) in the given namespace. This is either due to the fact that your linker doesn't know where to find the correct library or you are linking against a wrong version of the library that doesn't have the symbols. The other issues might be related to how the library was built and with what it was built (architecture, compiler, etc...). This we can't answer because we don't have enough information to know for sure.

Redis Problem compiling ReJSON Module for Windows

I have been trying to find or perhaps compile ReJSON Module for my Windows machine. I could not find any pre-compiled version of ReJSON Module that's why I thought of compiling it myself. So, I visited their GitHub page for source proceeded with following steps
1) Downloaded and Extracted the Zip Folder from https://github.com/RedisJSON/RedisJSON
2) Installed Cygwin with necessary packages
3) located the source directory and executed Make command
I got the following error
error: unrecognized command line option ‘-mmacosx-version-min=10.6’
Which I thought there is some configuration for MacOS in MakeFile. So, I searched all words with -mmacosx-version-min=10.6 and commented those lines so it could be excluded from Make process. It worked and showed some good progress but at the end now it gives some other errors
unrecognised emulation mode: acosx_version_min
I thought that I am doing it in wrong way. May be this ReJSON Module is simply not possible for Windows but there is no documentation about its eligibility for Windows. I am nowise in module compiling. Please show me some guidance. I am in desperate need of this ReJSON Module for Windows.
I am maintaining Redis for Windows fork and when I was working on version 4.0.x I ported ReJSON module to Windows as well, mainly for testing purposes and verification of changes related to modules in Redis for Windows itself. You can find the code here:
ReJSON module for Windows
This fork of ReJSON module should be still working and you should be able to compile it in Visual Studio, perhaps with small adjustments. If you do any - please submit a PR.

GTK 3 setup: Procedure entry point deflateSetHeader could not be located DLL libgio-2.0.0.dll

I am attempting to set up GTK3 for development on Windows 10 following the instructions on tarnyko.net
using the 64bit 3.6.4 bundle from here. The test program currently builds without errors, using the generated options. When I run the program a dialog appears displaying the error message:
Procedure entry point deflateSetHeader could not be located in the
synamic link library C:\Gtk\bin\libgio-2.0.0.dll
From what I can tell so far, deflateSetHeader is a function in zlib that was not present in older versions - a possible cause for the error. Looking in the header file of zlib that came with Gtk, it lists the function.
I have copies of zlib1 in my Gtk bin dir and MinGW (GCC v7.2.0) bin dir.
I tried swapping the versions between directories, but no joy. Don't have much else in my environment path variable, except for a vanilla Python 3.6 install. Don't have zlib1 in SysWOW64. I tried adding -lzlib1 to my gcc compiler options, but that didn't seem to make a difference. I'm running out of ideas now.
Anyone know what might be causing this?
Found the cause by searching my C drive for zlib and found a copy in
C:\Program Files\Intel\WiFi\bin that was causing the problem.

build a .exe for Windows from a python 3 script importing theano with pyinstaller

edit September, 2, 2017, 1pm
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. My description below has two aims: first it may help; second could anyone help me building a .exe for windows 7+, with the ‘theano’ module ?
reminder: My python 3 script opens a simple GUI made with Qt Designer in a ‘.ui’ file and imports pyqtgraph (with pyqt5), pymc3 (and thus theano that is required by pymc3), scipy, numpy, os, sys. It will be distributed on machines with Windows 7+. I tried to build a ‘.exe’ with py2exe, cx_freeze, pynsist and pyinstaller (I opened and updated several posts, this one is still opened: build a .exe for Windows from a python 3 script importing pyqtgraph and opening a GUI) but all failed. My best result (with pyinstaller) is described below after I had to give up theano.
the command line I ended up with is: pyinstaller —noupx —onefile —add-data “toto.ui;.” toto.py. But strangely:
1 the qt designer file ‘toto.ui’ is not included and must be distributed together with the .exe. Otherwise there is an error message when running the .exe saying toto.ui not found;
2 the ‘platforms’ directory from the ‘Library/plugin’ directory of the python environment must also be distributed along with the .exe. Otherwise there is an error message when running the .exe ‘this application has failed to start because it could not find the qt
platform plugin windows’ (but there is no error message from pyinstaller when building !)
3 the .exe is 220MB big ! it seems pyinstaller includes a bunch of useless things during the building.
pyqtgraph problem:
At first sight, the module ‘pyqtgraph’ seems to be incompatible with pyinstaller. Indeed, when the python code imports pyqtgraph, pyinstaller gives a SyntaxError: ‘yield’ inside async function. This seems to me very awkward (is this a bug in pyinstaller ?) because I had the impression from forums this is related to asynchronous generators that are only compatible with python 3.6, while pyinstaller works only with python 3.5- that is not compatible with asynchronous generators… so why does pyinstaller use this ? It turns out this bug-like feature is disabled in a new version of pyinstaller that is not released (and so not installed by default): pip install git+https://github.com/pyinstaller/pyinstaller, thanks to 9dogs (in comments). I also found it may help to explicitly write os.environ[‘PYQTGRAPH_QT_LIB'] = 'PyQt5’ or ‘PyQt4’ before importing pyqtgraph in the py file(s)
theano problem:
theano turns out to make several implicit imports that are not detected by pyinstaller. Thus the building looks ok but when running the .exe you get error messages like ‘no module theano.tensor.shared_randomstreams’. Unfortunately I failed to use the '--hidden-import' option of pyinstaller so I added explicitly the imports in the py file(s) (in this example ’import theano.tensor.shared_randomstreams’ ).
But this is not the end: after that, the file ‘…\AppData\Local\Temp_MEI35682\theano\gpuarray\blockgemv.c' is missing, leading to [4128] Failed to execute script. I don’t know what this file is and didn’t find information. I gave up and removed part of the GUI to avoid theano. Can anyone help me using theano with pyinstaller ?

On Windows, running “import tensorflow” generates No module named '_pywrap_tensorflow_internal' error

This is a different error than On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error as it points on _pywrap_tensorflow_internal. I also checked and MSVCP140.dll as suggested in the quoted question solution and it is on path (actually on multiple locations, is that a problem?)
For cpu I found the solution and it worked
Run below command it will clear all dependencies and then update it or remove and install the latest version of tensor flow
`pip install tensorflow==1.5`
I had the same issue for tensorflow with gpu supported library, I tried the answer written in this link
Cannot import Tensorflow for GPU on Windows 10
And it worked like a charm for me! Hope this helps you.
As specified in other answers the issue is related to python not being able to load some .dll files.
The generic solution to the problem in question would be to conduct the following steps:
Download and run processmonitor.aspx from technet.microsoft.com
Filter entries in Process Monitor by Process Name (user "Python.exe")
Run python interpreter
Type import tensorflow as tf and watch the results in Process Monitor
Entries in Process Monitor with Path column containing *.dll name and Result column having NAME NOT FOUND show exactly what is missing.
Assuming that you have correctly installed CUDA environment find out the dll from point 4 on you disk and include it in your path (I have specified a separate %CUDA_PATH% environment variable for that that is referenced from %PATH%)
If dll is not found go back to Tensorflow and CUDA tutorials on their integration.
In my case neither of CUDA nor Tensorflow docs specified clear enough for me what files should be included in the PATH after CUDA installation.
After struggling for 7 hours, I noticed that Tensorflow should be run under python 64 bit, while the default download file from python website is 32 bit.
Furthermore, Tensorflow work's only under python 3X under windows.
As mentioned by #wowas, this is due to the DLLs not working.
The nightly build with CUDA 9.0 worked for me following the instructions here

Resources