I have written different Python projects using PyQT5 and now trying to create their .exe files to make them standalone and executable but whenever I try using pyinstaller command:
pyinstaller --onefile myfile.py
the created .exe file always crashes. But in my other system, when create .exe files using the same pyinstaller command, the .exe files run well. So why am I having issues creating .exe files in this particular system? What could be wrong please? My files contains python classes of different widgets and the scripts run well in the editors, the GUIs open well when run from the editor but not as a standalone. Now I want them as standalone. I have also used auto-py-to-exe, same issue. How do I resolve this?
I am also attaching a screenshot of the pyinstaller details of both systems to this post. The two descriptions (details) are captured in the photo, the one on the larger screen is the one of the system I am having issues with, while the smaller display is the one of the system where the .exe files are created and runs successfully without any issue. I noticed in the one running successfully, the attributes are more compared to the one having an issue. The one without an issue has [recursive-copy meta data],[splash image file], [disable windowed traceback], [--target -architecture arch], [-codesign identity IDENTITY], [--osx-entitlements-filename-FILENAME] whereas the pyinstaller having issues in my other system does not have it.
The below is some of the errors I get.
Traceback (most recent call last):
File "f:\installed program files\python\python 39\lib\site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "f:\installed program files\python\python 39\lib\importlib\util.py", line 2, in <module>
from . import abc
File "f:\installed program files\python\python 39\lib\importlib\abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "f:\installed program files\python\python 39\lib\site-packages\typing.py", line 1359, in <module>
class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
File "f:\installed program files\python\python 39\lib\site-packages\typing.py", line 1007, in __new__
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
Remainder of file ignored
Error processing line 1 of f:\installed program files\python\python
39\lib\site-packages\zope.event-4.5.0-py3.6-nspkg.pth:
Traceback (most recent call last):
File "f:\installed program files\python\python 39\lib\site.py", line
169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "f:\installed program files\python\python 39\lib\importlib\util.py", line 2, in <module>
from . import abc
File "f:\installed program files\python\python 39\lib\importlib\abc.py",
line 17, in <module>
from typing import Protocol, runtime_checkable
File "f:\installed program files\python\python 39\lib\site-packages\typing.py", line 1359, in <module>
class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
File "f:\installed program files\python\python 39\lib\site-packages\typing.py", line 1007, in __new__
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
I have found a solution to it and hope others having similar issue who come across this post will use the suggestion too. I had to pip uninstall typing. i.e
pip uninstall typing
This helps fix whatever issue there was and my .exe files run well using pyinstaller without crashing. After uninstalling typing module, run the pyinstaller command again to create your executables.
Related
I am having an issue with a program, which uses panda3d. It works perfectly when executed as a pythonscript, but the version, which is compiled (or rather packaged) by PyInstaller throws the exception below.
:display(warning): Unable to load libpandagl.so: No error.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
File "Shipsim3d_1-1.py", line 930, in <module>
File "Shipsim3d_1-1.py", line 23, in __init__
File "direct/showbase/ShowBase.py", line 339, in __init__
File "direct/showbase/ShowBase.py", line 1024, in openDefaultWindow
File "direct/showbase/ShowBase.py", line 1059, in openMainWindow
File "direct/showbase/ShowBase.py", line 769, in openWindow
File "direct/showbase/ShowBase.py", line 749, in <lambda>
File "direct/showbase/ShowBase.py", line 821, in _doOpenWindow
File "direct/showbase/ShowBase.py", line 650, in makeDefaultPipe
File "direct/directnotify/Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.
[5466] Failed to execute script 'Shipsim3d_1-1' due to unhandled exception!
Usually, there is a Config.prc file in the etc subdirectory of the panda3d site-package directory. This file is non-existent in the packaged version. But if I create this subdirectory there, and copy the files to it as well, it still doesn't work and it still throws the same exception. There is a line "loadPrcData("win-size 1080 1920")" in my main program as well. Could this be part of the problem in any way? Or is there something else i am missing?
Thanks in advance
I solved this problem by including the whole panda3d lib:
pyinstaller --add-data="path/to/panda3d;panda3d" -wF main.py
When I am trying to run the spyder (Anaconda) I am getting the following Error:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 205, in main
mainwindow.main()
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3651, in main
mainwindow = run_spyder(app, options, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3526, in run_spyder
main.setup()
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 945, in setup
from spyder.plugins.ipythonconsole.plugin import IPythonConsole
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\plugin.py", line 46, in
from spyder.plugins.ipythonconsole.widgets import (ClientWidget,
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\__init__.py", line 16, in
from .debugging import DebuggingWidget
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\debugging.py", line 13, in
import pdb
File "C:\ProgramData\Anaconda3\lib\pdb.py", line 138, in
class Pdb(bdb.Bdb, cmd.Cmd):
AttributeError: module 'cmd' has no attribute 'Cmd'
Can someone please health me to resolve this issue?
I have created a file with the name cmd.py. After deleting the file (or rename the file), my problem got solved.
Do you happen to have a file named cmd.py in the same directory as the file you are trying to execute?
Cause If you are, then import cmd would not import the right python module. Instead, it would import your created "cmd.py" file.
I too faced this issue cause I had a file named "cmd.py" along with my python scripts and it would import that whenever I said import cmd. Renaming it helped me solve the issue
From my previous question: "Can't import the Python Imaging Library", I am still trying to convert cdr file to svg file, and the only solution I find for Debian is to use uniconvertor. So for the first time, I was missing the Pillow library (pip install Pillow). When tried to run for the second time, another error arose:
$uniconv image.cdr image.svg
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/uniconvertor/__init__.py", line 76, in <module>
saver(doc, sys.argv[2])
File "/usr/local/lib/python2.7/dist-packages/uniconvertor/app/plugins/plugins.py", line 201, in __call__
module.save(document, file, filename, options)
File "/usr/local/lib/python2.7/dist-packages/uniconvertor/app/plugins/Filters/svgsaver.py", line 299, in save
saver.Save()
File "/usr/local/lib/python2.7/dist-packages/uniconvertor/app/plugins/Filters/svgsaver.py", line 259, in Save
left, bottom, right, top = self.document.BoundingRect()
AttributeError: 'NoneType' object has no attribute 'BoundingRect'
But this time I would have to edit (with no python knowledge) the __init__.py script (main). So I am assuming the whole application is broken? How to fix it, or is there another package to make the conversion (cdr->svg)?
useing Pyinstaller packages a python script
Pyinstaller version 3.2
OS:Ubuntu
Traceback (most recent call last):
File "<string>", line 57, in <module>
File "<string>", line 29, in feature_extract
File "caffe/io.py", line 295, in load_image
File "skimage/io/_io.py", line 100, in imread
File "skimage/io/manage_plugins.py", line 194, in call_plugin
RuntimeError: No suitable plugin registered for imread.
You may load I/O plugins with the `skimage.io.use_plugin` command. A list of all available plugins can be found using `skimage.io.plugins()`.
file_test returned -1
I have been getting above error. Could some one please tell me how would i fix it?
The problem seems to be related to this github issue, essentially the skimage.io._plugins submodule is making life hard for Pyinstaller.
To make sure everything you need is packaged you should have a hook file that contains
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
datas = collect_data_files("skimage.io._plugins")
hiddenimports = collect_submodules('skimage.io._plugins')
(or if you already have a hook file with these, extend the current datas and hiddenimports).
So I'm confused about how to get pyinstaller to build an application that uses win32com. I have a script that runs with no problem from IDLE or command line that interacts with excel via
xl = Dispatch('Excel.Application')
followed by some other really basic excel calls, then closes. I've seen advice to include "clsctx=pythoncom.CLSCTX_LOCAL_SERVER" as an argument to Dispatch, but it doesn't change anything. Whenever I build the script, I get an error similar to this
Traceback (most recent call last):
File "<string>", line 7, in <module>
File "C:\Python27\trunk\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python27\trunk\iu.py", line 521, in doimport
exec co in mod.__dict__
File "Myskript\build\pyi.win32\Myskript\outPYZ1.pyz/win32com.client", line 11,
in <module>
File "C:\Python27\trunk\iu.py", line 436, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python27\trunk\iu.py", line 521, in doimport
exec co in mod.__dict__
File "Myskript\build\pyi.win32\Myskript\outPYZ1.pyz/win32com.client.gencache",
line 662, in <module>
File "Myskript\build\pyi.win32\Myskript\outPYZ1.pyz/win32com.client.gencache",
line 58, in __init__
File "Myskript\build\pyi.win32\Myskript\outPYZ1.pyz/win32com.client.gencache",
line 649, in Rebuild
File "Myskript\build\pyi.win32\Myskript\outPYZ1.pyz/win32com.client.gencache",
line 65, in _SaveDicts
File "Myskript\build\pyi.win32\Myskript\outPYZ1.pyz/win32com.client.gencache",
line 141, in GetGeneratePath
IOError: [Errno 22] invalid mode ('w') or filename: 'C:\\Python27\\trunk\\Myskri
pt\\dist\\Myskript.exe?844863\\__init__.py'
That's copied from this german question http://www.python-forum.de/viewtopic.php?f=1&t=25010 but my error is basically the same. I tried to implement the advice given on that page to no avail either.
I know next to nothing about COM stuff, just hoping to get this little excel app to run.
EDIT: Also tried importing pythoncom and running "CoInitialize()" (based on this guy Call MS Access module function from Python after compiling with py2exe fails saying that his script ran fine with pyinstaller) but that didn't change anything either. Really at a loss here and appreciate any advice.
I'm not sure if you are still using py2exe, i was about to try your workaround when i stumbled into this thread:
Call MS Access module function from Python after compiling with py2exe fails
The "solution" was using Pyinstaller that has a bunch of workarounds implemented on by default depending on your script. I tried it with my pywin32 script that uses excel and word com objects and it worked perfectly without any tweaks.