Kivy: PyInstaller not including Kivy modules upon compiling spec file - module

I've been following Creating Packages for Mac OS from Kivy.org in order to try and create a .app for my Kivy .py file.
However, despite following the guide through, my App never works, it crashes instantly upon opening. Pyinstaller's warning's concerning the build were dumped in a .txt that contained the following:
W: no module named kivy.graphics.ClearBuffers (top-level import by kivy.uix.screenmanager)
W: no module named kivy.core.spelling.SpellingBase (top-level import by kivy.core.spelling.spelling_enchant)
W: no module named kivy.core.image.ImageLoader (top-level import by kivy.core.image.img_gif)
W: no module named multiprocessing.RLock (top-level import by multiprocessing.sharedctypes)
and so on . . . (Full file is very long, but can be viewed here)
It seems like no kivy modules at all could be found, so they must have not been included for some reason. This is what I want to ask how to fix.
As of right now, I have been using the commands:
kivy pyinstaller.py myapp.py
kivy pyinstaller.py myapp.spec
respectively to create both the spec file and the App.
The spec file doesn't seem to have anything missing. (I've included the hooks and checked with a working spec file I used to create an .exe in the past)
# -*- mode: python -*-
# -*- coding: utf-8 -*-
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
install_hooks(globals())
a = Analysis(['Meep/Meep.py'],
pathex=['/Users/Owatch/Documents/pyinstaller/Meep'],
hiddenimports=[],
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='Meep',
debug=False,
strip=None,
upx=True,
console=False , icon='Meep/icon.icns')
coll = COLLECT(exe,Tree('/Users/Owatch/Desktop/examples/demo/touchtracer/'),
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='Meep')
Anyways, I'm not sure why this is occuring. My suspicions are mostly around the following:
1: I downloaded pyinstaller as a .zip since I could not find the .py file on my system. This is despite having it installed via pip on what I believe to be a separate python installation (I have 2.7 separately)
2: My reference to touchtracer is somehow wrong, it is linked to the touchtracer directory that came bundled in the dmg for Kivy. (A folder named Examples, which I dragged to my desktop)
Other than that, I'm afraid I'm pretty clueless. Thanks for helping (If you can!)

It appears that the error was associated with a flawed spec file. Nothing else to report.

Related

pyinstaller-ModuleNotFoundError, How to incl module which added manually by __init__.py in pyinstaller

I have my_ui.py and resources_rc.py are automatically generated from a QT GUI designer.
I can run my_ui.py using python my_ui.py.
This is my-module structure
\my-module
\__init__.py
\my_ui.py
\resouces_rc.py
Content of init.py. resource_rc will be imported and later used inside my_ui.py
from my-module import resources_rc
sys.modules['resource_rc'] = resources_rc
pyinstaller command:
pyinstaller --paths=resources_rc.py myui.py --onefile
I got an error message when running ./dist/my_ui
ModuleNotFoundError: No module named 'resources_rc'
I have tried to run pyinstalled outside my-module directory and still i get this error message.
Any idea how to solve this problem? Many thanks.

Importing Docstrings from Python modules using Sphinx and autodoc [duplicate]

I have faced a problem with Sphinx in Python. Even if I have followed the instructions from https://groups.google.com/forum/#!topic/sphinx-users/lO4CeNJQWjg I was not able to solve it.
I have Docs/source folder which contains:
conf.py
index.rst
RstFiles (the folder which contains .rst files for each module).
In conf.py I specify the abs path in the following way:
sys.path.insert(0, os.path.abspath('..'))
In index.rst I call all the modules from RstFiles folder in the following way:
.. toctree::
:maxdepth: 2
:caption: Contents:
BatchDataContainer.rst
BatchDefaultValues.rst
BatchTypes.rst
And finally, the content of each .rst file is in the following way:
BatchDataContainer
==================
.. automodule:: RstFiles.BatchDataContainer
:members:
When I run sphinx-build I get 2 main errors:
D:\hfTools\Projects\Validation-Source\Docs\source\RstFiles\BatchDataContainer.rst:
WARNING: document isn't included in any toctree
and
WARNING: autodoc: failed to import module 'BatchDataContainer' from
module 'RstFiles'; the following exception was raised: No module named
'RstFiles'
Any ideas what might be wrong cause I have tried different things already and nothing has helped?
If conf.py is located in this directory,
D:\hfTools\Projects\Validation-Source\Docs\source,
and the project's Python modules (including BatchDataContainer.py) are in
D:\hfTools\Projects\Validation-Source\Products,
then you need sys.path.insert(0, os.path.abspath('../..')) in conf.py.
The automodule directive needs to be updated as well:
.. automodule:: Products.BatchDataContainer
:members:

Import another python script, using PythonInterpreter

I am trying to execute a python method from eclipse using jython. I managed to run it with following code:
PythonInterpreter.initialize(System.getProperties(),
System.getProperties(), new String[0]);
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("Mypython.py");
interpreter.eval("MyClassName().MyMethodName()")
My problem is when I import another python script, which exists even in the same directory with Mypython.py. For example, when I add:
from food import Pizza
to Mypython.py, it starts to complain that cannot import. ImportError..
I found some questions about importing python libaries like os, but in my case this is not an issue.
I tried to make the folder as a package, add init.py etc but it failed. I saw some people use PySystemState, but I think it is for jython modules not user python scripts. if this is the solution please give me a simple example.
Could you please help me with that problem.
sys.path is your module-import search path. You can import sys and then modify sys.path as required.

OMP warning when numpy 1.8.0 is packaged with py2exe

import numpy
When I packaged above one line script as a single executable window application using py2exe, I get following warnings upon launch.
OMP: Warning #178: Function GetModuleHandleEx failed:
OMP: System error #126: The specified module could not be found.
This warning happen only when I build as single executable (i.e., only when bundle_files=1). Here's my setup.py for this.
from distutils.core import setup
import py2exe
setup(
options = {'py2exe': {'bundle_files': 1}},
windows=['testnumpy.py'],
zipfile = None,
)
This problem started with numpy 1.8.0. When I revert back to 1.6.2, the warnings don't show up.
Usually a single executable packaged by py2exe will catch warnings and traceback and save them into a log file. But somehow these warnings are not captured and the app creates a console window to show warning. I want to suppress this additional console window to show up.
How can I fix this warning problem?
What I tried (nothing worked):
I tried this redirecting sys.stderr.
I searched github numpy source for openMP assuming the OMP stands for it as mentioned here. But, nothing useful came out.
I have copied libiomp5md.dll to the same folder as setup.py.
I tried filterwarnings:
I tried sys.excepthook.
As I wrote in the comment, installing numpy 1.8.1rc1 from sourceforge did fix the issue, although I don't really know the differences...
I had this issue with numpy 1.13.1+mkl and scipy 1.19.1. Reverting to numpy 1.8.1rc1 is not an acceptable solution.
I tracked this issue to the scipy.integrate subpackage. The warning message pops up when this package is imported. It seems that perhaps libraries that use MKL don't like being invoked from library.zip, which is where py2exe places packages when using bundle option 2.
The solution is to exclude scipy and numpy in the py2exe setup script and copy their entire package folders into the distribution directory and add that directory to the system path at the top of the main python script.

Py2Exe and MatPlotLib: Plot won't Appear

I have a working Python 2.6 code using matplotlib, and would like to get a working exe out of it. I am having problems getting this accomplished:
Initially I got an error for missing MSCVP90.dll, but I downloaded that and extracted the .dll to the working directory and that error went away.
I had some errors regarding a missing tkagg module, but I added that to the exceptions and edited the matplotlibrc file to default to WXAgg instead and that went away.
The exe runs normally, but at the end of the code it is supposed to display a plot, and it doesn't. The plot is the main goal of this program, so it would be good to have this.
Just running the python code brings the plot up just fine.
Can anyone offer any suggestions or insights?
Here's my setup.py:
from distutils.core import setup
import py2exe
import matplotlib
matplotlib.use('wxagg') # overrule configuration
import pylab
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['_gtkagg', '_tkagg', 'backend_tkagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Thanks in advance!
Alright, I used pyinstaller and reverted the matplotlibrc file back to its original state where TkAgg was the default and everything works on my computer, but when I try to run it on another computer the plot still does not appear...
I can use pyinstaller to compile an exe out of a very simple matplotlib code, like:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
show()
But when I take that exe to another computer, it does not work.
Has anyone else had a similar issue? Any ideas?
Thanks
If the executable runs in your computer but doesn't work in another computer, the most likely problem is the lack of one or more of the required dlls that py2exe doesn't pack because license problems.
Very often these dlls are
gdiplus.dll
msvcp90.dll
Look for them in the computer where the exe works and copy them to the failing computer.
If the exe still doesn't work, check for other dll's. Py2exe gives the list of binary dependencies:
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
OLEAUT32.dll - C:\Windows\system32\OLEAUT32.dll
USER32.dll - C:\Windows\system32\USER32.dll
gdiplus.dll - gdiplus.dll
SHELL32.dll - C:\Windows\system32\SHELL32.dll
ole32.dll - C:\Windows\system32\ole32.dll
RPCRT4.dll - C:\Windows\system32\RPCRT4.dll
WSOCK32.dll - C:\Windows\system32\WSOCK32.dll
WINMM.dll - C:\Windows\system32\WINMM.dll
ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
msvcrt.dll - C:\Windows\system32\msvcrt.dll
WS2_32.dll - C:\Windows\system32\WS2_32.dll
WINSPOOL.DRV - C:\Windows\system32\WINSPOOL.DRV
GDI32.dll - C:\Windows\system32\GDI32.dll
IMM32.dll - C:\Windows\system32\IMM32.dll
MSVCP90.dll - C:\Python26\programas\test\MSVCP90.dll
KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
ntdll.dll - C:\Windows\system32\ntdll.dll
COMCTL32.dll - C:\Windows\system32\COMCTL32.dll
COMDLG32.dll - C:\Windows\system32\COMDLG32.dll
VERSION.dll - C:\Windows\system32\VERSION.dll
C:\Python26\programas\test>
Finally, I succesfully got a functional matplotlib program executable with py2exe. I only needed to add an 'includes' to setup.py and set WXAgg as the backend in matplotlib.rc (with Tk I got the same problem you described...). For it to work, I had to set WXAgg in the original matplotlib.rc (in the matplotlib/mpl-data folder). This is the one py2exe imports (not the one in the user's matplotlib configuration directory). To be sure check the .rc file in your dist folder.
from distutils.core import setup
import py2exe
import matplotlib
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['Tkconstants','Tkinter', 'tcl'],
'includes': ['matplotlib.backends.backend_wxagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Today I lost one day of work with this, so...
The solution is to include "FileDialog" module explicity, because the "six" module uses it. Specifically, I solved my problem by including six, dateutil, FileDialog, matplotlib, pylab, matplotlib.backends.backend_tkagg and others.
Good Luck!