Is uniconvertor application broken for debian 10? - python

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)?

Related

Why do my Pyinstaller created .exe files keep crashing on start-up

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.

Py2exe NotImplementedError: resource_filename() only supported for .egg, not .zip

I am trying to convert a python file into an executable and for that I'm using py2exe. When running the setup.py script to generate the dist folder and the executable file everything goes well.
What goes wrong is that when I'm running the executable the following error message gets displayed:
Traceback (most recent call last):
File "q400.py", line 16, in <module>
File "SUAVE\__init__.pyc", line 12, in <module>
File "SUAVE\Plugins\__init__.pyc", line 11, in <module>
File "SUAVE\Plugins\load_plugin.pyc", line 37, in load_plugin
File "SUAVE\Plugins\pint\__init__.pyc", line 23, in <module>
File "SUAVE\Plugins\pint\unit.pyc", line 423, in __init__
File "pkg_resources\__init__.pyc", line 1171, in resource_filename
File "pkg_resources\__init__.pyc", line 1872, in get_resource_filename
NotImplementedError: resource_filename() only supported for .egg, not .zip
When I check the file unit.pyc at line 423 the code is:
data = pkg_resources.resource_filename(__name__, 'default_en.txt')
And when I check the library.zip in the dist folder there is no default_en.txt file, however, it is present in the site-packages module.
So is it because this file is a txt file that this error shows up?
I tried to force py2exe to import it but with no success.
Also I found a similar question here but the answer can't be applied in my case because I don't have any egg nor zip files implicated in the error (at least in my opinion).
Thank you

Can't run python script converted to exe

I have created a python program that sends data to google spreadsheets using the following external libaries:
json
gspread
oauth2client
The program works as expected, however when I tried to convert it to an executable, I would get the following error every time I rune the .exe file:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "Demo.py", line 13, in <module>
File "C:\Python27\lib\site-packages\oauth2client\util.py", line 140, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 1630, in __init__
_RequireCryptoOrDie()
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 1581, in _RequireCryptoOrDie
raise CryptoUnavailableError('No crypto library available')
oauth2client.client.CryptoUnavailableError: No crypto library available
Would any of you guys know what the problem could be, and what steps I could take to solve it?
Thanks in advance
Edit: I tried to use both cx_freeze and py2exe. I got similar errors in both
Below is the setup.py I used in cx_freeze:
from cx_Freeze import setup, Executable
setup(name = "Demo" ,
version = "1.0" ,
description = "A python Demo" ,
executables = [Executable("Demo.py")])

PyInstaller "You may load I/O plugins with the `skimage.io.use_plugin`"

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).

Freezing (.exe) a traitsUI program, realistically feasible?

I'm trying to freeze with either cx_freeze or pyInstaller a TraitsUI program that makes use of Chaco, Traits, TraitsUI and to a lesser extent mayavi (could actually be taken out). I need this to run on mac, linux, ubuntu so am avoiding py2exe. I've intentionally uninstalled pyqt and pyside so that only the wx backend is available.
Using cx_freeze, I encountered and reported a bug, so pyInstaller seems to be getting me the furthest. It generated an .exe file, but when I run the file I get warnings and an error. To generate the .exe file I did:
pyinstaller --onefile --name=pameapp pamemain.py
pyinstaller pameapp.exe
Upon running, the warnings are:
Warning: Unable to import the wx backend for pyface due to traceback: Traceback (most recent call last):
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/pyface.toolkit", line 45, in _init_toolkit
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/pyface.toolkit", line 31, in import_toolkit
ImportError: No module named wx.init
Warning: Unable to import the qt4 backend for pyface due to traceback: Traceback (most recent call last):
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/pyface.toolkit", line 45, in _init_toolkit
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/pyface.toolkit", line 31, in import_toolkit
ImportError: No module named init
Warning: Unable to import the null backend for pyface due to traceback: Traceback (most recent call last):
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/pyface.toolkit", line 45, in _init_toolkit
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/pyface.toolkit", line 31, in import_toolkit
ImportError: No module named null.init
In addition, I get the following error:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "/home/glue/anaconda/envs/fibersim/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.api", line 35, in <module>
File "/home/glue/anaconda/envs/fibersim/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.editors", line 22, in <module>
File "/home/glue/anaconda/envs/fibersim/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.editors.api", line 10, in <module>
File "/home/glue/anaconda/envs/fibersim/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.editors.code_editor", line 36, in <module>
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.editors.code_editor", line 48, in ToolkitEditorFactory
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traits.traits", line 487, in __call__
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traits.traits", line 1191, in Color
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.toolkit_traits", line 7, in ColorTrait
File "/home/glue/Desktop/fibersim/pame/build/pameapp/out00-PYZ.pyz/traitsui.toolkit", line 137, in toolkit
traits.trait_errors.TraitError: Could not find any UI toolkit called 'null'
pyface probably has a lot of dynamic imports, so this must be a problem encountered by anyone who tries to freeze ETS. Is there a single fix to get this working?
Considering the older stuff floating around the web on success rates to freezing an ETS program, is it even worth further investment? To us, having people avoid configuring python for this application would be a huge plus.
Thanks.
Pyface.toolkit you are using is using dynamic import:
def import_toolkit(tk):
try:
# Try and import the toolkit's pyface backend init module.
be = 'pyface.ui.%s.' % tk
__import__(be + 'init')
except:
raise
return be
So pyinstaller is not able to detect this. Check with python -v b.py 2>&1 | grep imp what is the specific import and add hook file (hook-.py) with proper hiddenimports list.
However I've did some tests in local and I am not able to do working test schema with __import__. It's strange as I did some debugging and I found that hiddenimport is added but still not usable.

Categories

Resources