I am new on stack overflow and I hope I am not asking something obvious. In fact, I did quite a search online and I could not find a proper answer/solution to my problem.
I am building an open-source cross-platform desktop application based on python. I am using cx_freeze to build a distribution version. The cx_freeze works well on Windows 7 and Mac OS X 10.9.2 and the app are already built. Nonetheless, when I try to use the same setup.py file to build the diet_version on Linux 13.10, I get the following error:
My building options are:
build_exe_options = {"includes":["matplotlib.backends.backend_tkagg","sys","os","PyQt4","numpy","sys","os","matplotlib"],
"include_files":[(matplotlib.get_data_path(), 'mpl-data')],
"excludes":[],
}
and I get the following error:
error: build/exe.linux-x86_64-2.7/mpl-data: Is a directory
I tried to use the full path of mpl-data in the building options, i.e.
build_exe_options = {"includes":["matplotlib.backends.backend_tkagg","sys","os","PyQt4","numpy","sys","os","matplotlib"],
"include_files":[("/usr/share/matplotlib/mpl-data", 'mpl-data'), ("/usr/share/matplotlib/mpl-data/fonts", 'mpl-data/fonts'),("/usr/share/matplotlib/mpl-data/images", 'mpl-data/images'),("/etc/matplotlibrc", 'mpl-data')],
"excludes":[],
}
but I keep getting the same error mentioned above.
If I do not declare the build_exe options, as I did on Windows 7, I get the following error on Linux:
error: /usr/lib/pymodules/python2.7/matplotlib/mpl-data: No such file or directory
I am afraid the error happens because mpl-data is located in $/usr/share/matplotlib/mpl-data rather than $/usr/lib/pymodules/python2.7/matplotlib/mpl-data, but I have no clue why the error persists even after declaring the path to the folder.
To sum up, I release the desktop app for windows and mac os without any problems (works like a charm!), but the linux version is still pending a stand-alone version (check the Linux source code here: http://concrete.fsv.cvut.cz/~wilson/Software.html). Can anybody shed some light on this issue? How to tell cx_freeze to get the mpldata without errors.
Thanks in advance,
Wbr
Related
I'm running clang on mac to compile a c file created by running a very simple program through cython, but the compiler always give me a "Python.h not found" fatal error. I've tried every solution I could find, reinstalling python 3.9, using the -I/path/to/headerfile method, and rewriting the include statement in the code to contain the full filepath, but nothing has worked. When I do include the full filepath, I get fatal error: 'cpython/initconfig.h' file not found. What could the issue possibly be, and how would I fix it? The program itself works fine in the standard python interpreter, pyinstaller, and nuitka.
Today I needed to embed Python into a C application developed on XCode with Clang compiler, and I've met the same problems and solved them. Let me share the tips:
1. Python not found error
You should install a Python framework to your MacOS, and attach it into Frameworks and Libraries project settings tab. Also, specify it's path in Framework Search Paths inside Build Settings tab if XCode hasn't done it automatically.
2. Undefined symbols / Implicit declaration errors
Verify you're using a modern version of Python framework. Versions prior to 3.6 had different ABI which leads to the mentioned errors.
3. cpython/initconfig.h file not found
Versions prior to ~3.9 had some header inclusion problem for the cpython/initconfig.h file (issues 40642, 39026).
Check the builds of Python that your OS currently has. I found Pythons installed in the following paths:
# Default 2.7 MacOSX installation is here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/
/Library/Frameworks/
Or install a recent Python version. I recommend using "universal binary" build, see the docs.
I'm running a python function in Matlab and when I run I got the error:
This application failed to start because it could not find or load the
Qt plataform plugin 'windows' in '' '' , Available plugins are:
minimal offscreen, windows. Reinstalling the application may fix this
problem.
I already followed the steps in this video copying the platform folder to pyqt tools and in this post add to the environment path.
If I run my code in python it works fine, It seems that Matlab is not finding the Qt platform plugin 'Windows'
Someone can help me, please?
This is the problem of deploying Qt applications. Depending on platform you're using you can find tool for deploying, it is in Qt directory. For example, on my PC with Windows this is:
c:\Qt\5.15.0\mingw81_64\bin\windeployqt.exe
You can call this tool like this:
windeployqt <path-to-app-binary>
// OR
windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
There are many other options like --debug, --release, etc. Too see all of them, just call windeployqt.
On other platforms it could be linuxdeployqt, macdeployqt, also pyqtdeploy.
After calling this tool it will copy all required submodules to (near) your app, so it will find all it needs.
On my Windows system, I had the same experience that the Python function ran natively, but would not run via MATLAB. The problem was missing or incompatible dlls (not exe) files. To solve the problem I copied the exact dlls from my conda environment into the MATLAB \bin\win64 folder. That is, I copied these five dlls
qdirect2d.dll
qminimal.dll
qoffscreen.dll
qwebgl.dll
qwindows.dll
from the \Library\plugins\platforms folder of my conda environment
C:\Users\username\AppData\Local\Continuum\envs\myenv\Library\plugins\platforms
into the MATLAB folder
C:\Program Files\MATLAB\R2020b\bin\win64\platforms
While doing the copy, I overwrote three dlls which already existed in the MATLAB folder.
I'm in trouble with cx_Freeze 5.0
I'm working on:
Windows 10 LTSB x64
Python 3.4.4 x86
PyQt5
PyWin32 x86
I never had any issue with this process until I reinstall my Windows10 installation... it was working great and now I can't figured it out why it's happening ...
When I Freeze my python app (python setup.py build) script is copying the whole python libraries outside the python34.zip.
The only thing I got inside python34.zip is *.pyc files (only this.. but a lot)
I don't know why it doesnt include python libraries now and didnt find any options/config, it has to include this automatically ...
If someone can help with this.. :)
Note: nothing has changed in my setup.py, simple setup.py file, copied from standard example just including one asset folder (this one is correctly copied.. no issues)
Thanks !
cx_Freeze build output
I encountered the same problem (if it is indeed a problem) after upgrading to cx_Freeze 5.x. I believe it's mentioned in the changelog here: https://cx-freeze.readthedocs.io/en/latest/releasenotes.html
Added support for storing packages in the file system instead of in
the zip file. There are a number of packages that assume that they are
found in the file system and if found in a zip file instead produce
strange errors. The default is now to store packages in the file
system but a method is available to place packages in the zip file if
they are known to behave properly when placed there. (Issue #73)
(emphasis mine)
That "method" is apparently described in https://cx-freeze.readthedocs.io/en/latest/distutils.html#build-exe, specifically the zip_include_packages and zip_exclude_packages options.
I ended up putting the following as a keyword argument to my setup() call, which solved it for me:
options = {"build_exe": {"include_msvcr": True, "include_files": dataFiles, "packages": ["lxml", "idna"], "zip_include_packages": "*", "zip_exclude_packages": ""}},
I am a newbie to Stack Overflow (first post), but really see the use of this website.
I'm stumped. We are trying to setup IIS 7.0 to run with WinPython 2.7 on a Windows 7 machine.
I am an IIS newb, but veteran Python user. IIS 7 can NOT find a library, which python finds, and executes, perfectly when ran on it's own. When executed via IIS, the script fails with a traceback, and IIS returns the 502.2.
I found this thread http://forums.iis.net/p/1209465/2073173.aspx?HTTP+Error+502+2+Bad+Gateway+Frustrations but the advised solution is simply another troubleshooting suggestion.
I found IIS's description (http://support.microsoft.com/kb/942057) of the error helpful, but futile.
I found Python's start-up options/parameters helpful (http://docs.python.org/2/using/cmdline.html), but futile.
I found IIS's advice for configuring Python helpful (http://support.microsoft.com/kb/276494, but (questionably?) incomplete.
This thread on manually defining an alternate bin folder (http://forums.asp.net/t/1303052.aspx?Tell+IIS+to+load+dll+from+another+directory+not+Bin+web+config+) might be where my solution lies, but I don't think it is because of the fact that this all worked on 2.6 without doing that to IIS.
IIS seems to allow python to import any module that is just a python script. As soon as it gets to a *.pyd (basically just python's version of a dll file) file, it screams. I'm no pro when it comes to DLLs and windows environments, but wouldn't IIS have to have paths to a bin folder of some kind? Do I have to manually edit them, as discussed in the last link above?
ACTUAL ERROR Details below for DLL failed Load:
The Error :
" HTTP Error 502.2 - Bad Gateway The specified CGI application
misbehaved by not returning a complete set of HTTP headers. The
headers it did return are "Traceback (most recent call last): File
"\estorage.equitable.int\riskmgmt\Quants\web\LinksPage.py", line 2,
in import pyweb File
"\estorage.equitable.int\riskmgmt\Quants\Common2014\Python\pyweb__init__.py",
line 5, in from core import * File
"\estorage.equitable.int\riskmgmt\Quants\Common2014\Python\pyweb\core.py",
line 2, in from pylib import pgdb File
"\estorage.equitable.int\riskmgmt\Quants\Common2014\Python\pylib\pgdb.py",
line 8, in from scikits import timeseries as ts File
"C:\WinPython-32bit-2.7.6.2-20140401\python-2.7.6\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries__init__.py",
line 13, in import const File
"C:\WinPython-32bit-2.7.6.2-20140401\python-2.7.6\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py",
line 79, in from cseries import freq_constants ImportError:
DLL load failed: The specified module could not be found. ".
I'm confident that the python environment is configured properly, as the script runs from the same executable (python.exe) via a command line. I'm thinking that I don't have IIS configured properly, for the new Python 2.7 install. The same script worked yesterday, on IIS and python 2.6. But during our upgrade from 2.6 to 2.7, a bunch of PATH and PYTHONPATH parameters all changed, plus we went from ActivePython to WinPython. WinPython is "registered" on the machine.
What I've tried
confirming python's sys.path is as expected at run-time in both IIS and command line - it is.
using the module from python command line.
recompiling the failing module using two different compilers (ming32 and VS2008).
putting duplicates of my new 2.7 modules in the old python26 folder.
pulling out lots of hair and other hacky stuff.
My next step, is to post this same message on a python forum. If anybody can advise on a good one for python-IIS related challenges, that would be appreciated.
Please help! Thanks in advance.
I got this 502.2 error when doing a clean installation of PHP 5.5 in Windows Server 2012 R2 with IIS 8.5.
It turns out PHP is a Visual C++ application which needs the library MSVCR110.dll in order to run properly. My computer does not have Visual Studio 2012 installed and thus it does not have this file. I got my problem solved by installing the Visual C++ Redistributable Packages https://www.microsoft.com/en-us/download/details.aspx?id=30679#
(Note: jc77 is my associate, and I'm actually the OP, as this was an x-post from IIS forums.)
We solved the problem.
tl,dr; portable python + sloppy/rookie compiling = strange behaviour + frustrations.
Bottom line, compile properly. For scikits.timeseries, using ming32 everything will walk, talk, and sound like it works in Spyder.exe, but not in python.exe. You have to use VS2008, if you want it to work in both.
More Info:
Winpython (as well as others) presents itself as identical to any other python installations, if you "register" the installation. It works great, 99% of the time. We learned the hard way, that "Winpython Interpreter.exe" and "python.exe" provided in the install are in fact different. Can't explain why, but the two executables gave different behavior. We were doing all our testing in Spyder, which must use "winpython interpreter.exe". The module which IIS couldn't find, would import and run no problem in Spyder. Then, in IIS, using python.exe, the module wouldn't import. We were operating on the assumption that the IDE would use python.exe, and that the stack was identical. As, 99% of the time, they appear to be. The way we were compiling scikits worked in winpython interpreter.exe. We were making a rookie mistake when compiling scikits, but it went un-noticed because it was working fine in our IDE (Spyder).
I'm adding these keywords for others : Anybody else who receives errors like this is likely using a portable python installation AND not compiling something properly. Winpython, Portable Python, eGenix, [and possibly?] Active State and Enthought Canopy.
While trying to configure CGI to run Perl in Windows 8.1, I had HTTP Error 502.2, but then I read loste's post and solved the problem. I had previously installed both Perl64 and Strawberry Perl. Although the IIS EventHandler pointed to only the Perl64 directory, both directories appeared in my Windows PATH variable. I prefer Strawberry Perl, so I changed the EventHandler to point to the Strawberry Perl directory and deleted the paths to Perl64 from the Windows PATH variable to solve the error.
Try this
print("Content-Type: text/html\n")
print("Hello Python World!")
You must specify the type of document
I'm using CXFreeze with PySide (QT). I get an error:
cx_Freeze: Python error in main script.
myscript.py line 33, in
File ExtensionLoader_Pyside_QtGUI.py, line 11, in
Import Error: DLL load failed: The specified module could not be found
When running a fresh install of Windows server 2008.
I'm running the frozen EXE package (with the folder). It seems to work on my own system and other systems. What might be the issue?
After reading, online, I tried to replace the Qt4Gui file, but this didn't solve the issue.
Python version is 2.7
Based on your Import Error: DLL load failed it is most likely an installation issue causing the missing DLL. To figure our exactly which DLL you are missing, use http://www.dependencywalker.com/ Run the .exe and open the .pyd file for File ExtensionLoader_Pyside_QtGUI.py and it will show you exactly which DLL's are missing and more importantly the locations where they should be. You can probably then track down the missing DLL online.
there are known issues with pyside 1.2.0 and cxFreeze. All should be fixed in development version (available on git repo). Please build the PySide from latest sources yourself or wait for PySide version 1.2.1. Build instructions are here [1].
[1] https://github.com/PySide/pyside-setup#building-pyside-on-a-windows-system
I used Py2exe instead of CXFreeze and it worked perfectly.
Also, apparently Python requires the MS Visual C++ Dependency Files:
http://www.microsoft.com/en-us/download/details.aspx?id=29
So any bundling needs that as well, if it's a fresh install. (Although I think they are now bundled with newer Windows versions.)
Other Notes:
In my experience, sometimes you should try CXFreeze, Py2EXE and PyInstaller quickly and see if one works best. As ideal as CXFreeze is re: cross platform, it just isn't going to happen perfectly.
Also, while I don't know if this was a factor, I set up a Windows 2000 Pro virtual machine and ran Py2exe on that. That was to ensure compatibility for all older Windows versions, and seemed to work well. (NOTE: Many things won't even run on Win2000 anymore so be careful that your other tools and libraries will run on it.)
Finally, be extra careful to match the bit level (32 vs 64) of all your libraries, and your Python install itself. If you have 32-bit python, ensure that your PySide, CXFreeze and any other libraries you use are 32-bit. (Or 64-bit if you're using 64-bit python.)