I've trouble making an CONSOLE app work after packaging.
App flashes once and closes.
in terminal i've put: pyinstaller --onefile --windowed --icon=name.icns Script.py
So far i've tried running the app through terminal to try and get error ( you know like in windows but it failed lol ).
Is there a way to see the reason why it closed?
EDIT:
When i run Executable within app i get this error:
File "Script.py", line 14, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages/requests/__init__.py", line 43, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages/urllib3/__init__.py", line 8, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages/urllib3/connectionpool.py", line 28, in <module>
File "site-packages/urllib3/packages/six.py", line 92, in __get__
File "site-packages/urllib3/packages/six.py", line 115, in _resolve
File "site-packages/urllib3/packages/six.py", line 82, in _import_module
ImportError: No module named 'queue'
I have nothing about "queue" in code and .py works great and gives no import error.
Thank you.
Seems like there's an error importing one of your modules, perhaps its dependencies aren't being detected correctly.
You can try to explicitly add a module via the command line by including --hidden-import=queue, you might have to do this for more modules that haven't been detected. More discussion in this question.
Related
I am trying to make an executebale out of a .py script I have, in a virtual environment with pyinstaller. however after making my executeable with pyinstaller --onefile myprogram.py when running the resulting myprogram.exe from command prompt, I get this error:
Traceback (most recent call last):
File "myprogram.py", line 4, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\IPython\__init__.py", line 48, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\IPython\core\application.py", line 23, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\traitlets\config\__init__.py", line 6, in <module>
File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "site-packages\traitlets\config\application.py", line 17, in <module>
ImportError: No module named decorator
decorator is installed in the env I'm working in so that is not the problem (python 2.7.17, pyinstaller 3.5, windows 10, anaconda)
thanks in advance!
So this is the error it's throwing in cmd windows 10. Seems to be something to do with pynput? Not really sure what I can do to fix this and appreciate any help.
C:\Users\Michael\Desktop\herprogram\dist\beeb>beeb.exe
Traceback (most recent call last):
File "C:\Users\Michael\Desktop\herprogram\beeb.py", line 5, in <module>
import pynput
File "c:\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pynput\__init__.py", line 40, in <module>
File "c:\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pynput\keyboard\__init__.py", line 31, in <module>
File "pynput\_util\__init__.py", line 76, in backend
ImportError
[11880] Failed to execute script beeb
Many thanks
I switched to a different module pywinauto which is officially supported by pyinstaller and used:
import pywinauto
pywinauto.mouse.double_click(button='left', coords=(0, 0))
This solved the issue. Thanks guys
Trying to distribute a program that relies on tensorflow...
Using tensorflow it works nicely both as script and with pyinstaller.
Using tensorflow-gpu it works as script but not with pyinstaller.
The cuda and cudnn dlls have been copied into the bundle folder by pyinstaller.
I use python 3.6.5 and tensorflow 1.7.0. (Can change version if it helps...)
Error message:
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib__init__.py", line 126, in import_module
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "interface.py", line 14, in
File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "site-packages\tensorflow__init__.py", line 24, in
File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "site-packages\tensorflow\python__init__.py", line 49, in
File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
ImportError: Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
File "importlib__init__.py", line 126, in import_module
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[10816] Failed to execute script interface
Make sure you are also packaging MSVCP140.DLL, as missing this from the %PATH% can throw this error.
I tend to use cx_Freeze instead of pyinstaller when distributing tensorflow applications. Once you overcome the error cx_Freeze has with scipy, it's simpler overall.
Maybe this can help. I manually rename the file _pywrap_tensorflow_internal.pyd to tensorflow.python._pywrap_tensorflow_internal.pyd in the dist folder. Everything works.
I fixed this problem by making dirs as ".../dist/[MmyPyName]/tensorflow/python/_pywrap_tensorflow_internal.pyd"
tensorflow-gpu = 1.10.0
python = 3.6.2
cuda = 9.0
cudnn = 7.3.0
When installing it with pyinstaller, make sure that in the .spec file include this as hidden import:
hiddenimports=['tensorflow.python._pywrap_tensorflow_internal',],
This will include the missing module in the correct path.
I have this Python script which I want to run on other windows computers without python.So i have tried py2exe and pyinstaller but none of these work as when I try copy the .exe file to an other system and run it but I get an ERROR:
Traceback (most recent call last):
File "client.pyw", line 4, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "gtk\__init__.pyo", line 30, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "gobject\__init__.pyo", line 26, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "glib\__init__.pyo", line 22, in <module>
File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading glib\_glib.pyd
You can try cx_Freeze or include Python installing to program installer (may be a batch script):
msiexec /i /quiet /passive python.msi
When needing to make an executable out of a Python script, I found py2exe (or its GUI brother GUI2Exe to be the most useful tools. There are a few other options.
I'm trying to deploy my python application using py2app.
I created the setup file using : py2applet --make-setup MyApplication.py
Then I did this to test it : python setup.py py2app -A
That worked as well. My GUI program runs.
When I try the last step: python setup.py py2app
I get this fat error.
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 659, in run
self._run()
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 959, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/usr/local/lib/python2.7/site-packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/usr/local/lib/python2.7/site-packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
Why is this happening? I've spend the last few hours trying to deploy. No luck with py2app, cx_freeze, etc.
Here is a workaround: edit the file MachOGraph.py which in your case is located there:
/usr/local/lib/python2.7/site-packages/macholib/MachOGraph.py
Search for the term loader=loader.filename) and replace it with loader_path=loader.filename)
Credits goes to David Goldenberg for its post on bitbucket.org. https://bitbucket.org/ronaldoussoren/py2app/issues/137/py2app-problems-using-enthought-python
Pillow was the problem. Py2Applet doesn't play nice with it. Got rid of Pillow, and all is well.