Can't perform this operation for unregistered loader type - Is there any workaround the fact that pkg_resources are not supported by pyinstaller? - python-3.6

I'm new to pyinstaller and I'm getting this error (NotImplementedError: Can't perform this operation for unregistered loader type) when I try to import a file with my App.
The complete traceback is:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1702, in __call__
File "BioRank.py", line 190, in load
File "site-packages\pandas\core\frame.py", line 710, in style
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "C:\Users\tizma\Anaconda3\lib\site-
packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pandas\io\formats\style.py", line 50, in <module>
File "site-packages\pandas\io\formats\style.py", line 111, in Styler
File "site-packages\jinja2\environment.py", line 830, in get_template
File "site-packages\jinja2\environment.py", line 804, in _load_template
File "site-packages\jinja2\loaders.py", line 113, in load
File "site-packages\jinja2\loaders.py", line 234, in get_source
File "site-packages\pkg_resources\__init__.py", line 1396, in has_resource
File "site-packages\pkg_resources\__init__.py", line 1449, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
I did some research and found out that pyinstaller does not support pkg_resources. Is there any workaround this issue?

I have faced this problem using pyinstaller. The solution was to edit your-python-path\Lib\site-packages\pandas\io\formats\stytle:
Go to line 120 and change
template = env.**get_template**("html.tpl")
to
template = env.**from_string**("html.tpl")
Then try again.
My problem was I was using background color in pd.Series("backgroud....) and the pyinstaller was not building it, so after the change it works.

I experienced the exact same issue with pyinstaller not including pkg_resources. Rafael's answer above sorted it out for me. Much simpler than the other solutions I found related to this issue. I needed to edit the style.py file. This solution also doesn't require any additional datas in the spec file which is convenient.
Path:
your_path\venv\Lib\site-packages\pandas\io\formats\style.py
Before:
template = env.get_template("html.tpl")
After:
template = env.from_string("html.tpl")

Related

Failing to train Google Colab: Custom Training StyleGan2-ADA

I've been trying to get the following colab notbook to work without success.
I was able to scrape images needed and (hopefully) resized them all to 256x256.
After connecting my drive and following all steps, I reached the training part.
There, I am using the default values with: resume_from = "ffhq256"
The process start but ends after ~20 secods with the following error:
Constructing networks...
Setting up TensorFlow plugin "fused_bias_act.cu": Compiling... Loading... Done.
Setting up TensorFlow plugin "upfirdn_2d.cu": Compiling... Loading... Done.
Resuming from "https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/transfer-learning-source-nets/ffhq-res256-mirror-paper256-noaug.pkl"
Downloading https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/transfer-learning-source-nets/ffhq-res256-mirror-paper256-noaug.pkl ... done
Traceback (most recent call last):
File "train.py", line 645, in <module>
main()
File "train.py", line 637, in main
run_training(**vars(args))
File "train.py", line 522, in run_training
training_loop.training_loop(**training_options)
File "/content/drive/MyDrive/colab-sg2-ada/stylegan2-ada/training/training_loop.py", line 129, in training_loop
G.copy_vars_from(rG)
File "/content/drive/MyDrive/colab-sg2-ada/stylegan2-ada/dnnlib/tflib/network.py", line 512, in copy_vars_from
self._components[name].copy_vars_from(src_comp)
File "/content/drive/MyDrive/colab-sg2-ada/stylegan2-ada/dnnlib/tflib/network.py", line 509, in copy_vars_from
self.copy_own_vars_from(src_net)
File "/content/drive/MyDrive/colab-sg2-ada/stylegan2-ada/dnnlib/tflib/network.py", line 482, in copy_own_vars_from
tfutil.set_vars({self._get_vars()[name]: value for name, value in value_dict.items() if name in self._get_vars()})
File "/content/drive/MyDrive/colab-sg2-ada/stylegan2-ada/dnnlib/tflib/tfutil.py", line 227, in set_vars
run(ops, feed_dict)
File "/content/drive/MyDrive/colab-sg2-ada/stylegan2-ada/dnnlib/tflib/tfutil.py", line 33, in run
return tf.get_default_session().run(*args, **kwargs)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 956, in run
run_metadata_ptr)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1156, in _run
(np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (3, 3, 512, 256) for Tensor 'G_synthesis/64x64/Conv0_up/weight/new_value:0', which has shape '(3, 3, 512, 512)'
Any help would be greatly appreciated!

debugging ZEXP import - no module named

I am attempting to zexp import a site from what should have been the same Plone version and addon packages. However, when I do so I get
Module ZPublisher.Publish, line 60, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module OFS.ObjectManager, line 620, in manage_importObject
Module OFS.ObjectManager, line 638, in _importObjectFromFile
Module ZODB.ExportImport, line 92, in importFile
Module transaction._transaction, line 260, in savepoint
Module transaction._transaction, line 257, in savepoint
Module transaction._transaction, line 690, in __init__
Module ZODB.Connection, line 1123, in savepoint
Module ZODB.Connection, line 587, in _commit
Module ZODB.ExportImport, line 176, in _importDuringCommit
ImportError: No module named MyOldPackage.Content
This is an old Archetypes class that has since been migrated to a replacement in Dexterity. I thought I had removed all references but apparently something got missed. I get that I have to remove all objects that use this class but there's the rub - how do I find which objects use them?
I thought I had found something in the CMFEditions tools but that might be a red herring. Trying to export portal_historiesstorage yields the same error so I thought perhaps some old versions of past content were stuck there. Deleted shadow storage and rebuilt it, so it's now blank (ZMI page confirms this). But I'm still getting the error when trying to import just this tool - how is it still trying to reference this class? This is why I think it might be a red herring and it's inheriting something from the portal object, but I'm having a rough time trying to find where this class is referenced.
edit:
It looks like I have something bad in zvc_repo - I'm not sure the difference in what shadow storage and this are supposed to do. Here's a proposed script. Can anyone with better CMFEditions or ZopeVersionControl comment on how this sounds?
tool = portal.portal_historiesstorage
from ZODB.broken import PersistentBroken
bad_repo_ids = set()
for sequence in tool.zvc_repo._histories:
for version in tool.zvc_repo[sequence]._versions:
obj = tool.zvc_repo[sequence].getVersionById(version)._data._object.object
if isinstance(obj, PersistentBroken):
bad_repo_ids.add(sequence)
for bid in bad_repo_ids:
del tool.zvc_repo._histories[bid]

How do I enable through-the-filesystem diazo editing with plone 4.3

Summary: through-the-filesystem editing not working for my diazo theme. Plone breaks.
Details:
I've created my first live plone site with 4.3.2 and diazo. You can see the live version at borogreen.org. I would like to keep editing the theme forward.
My ubuntu 12.04LTS test server has only plone432 + diazo + dexterity (not used) + Static resource storage 1.0.2 enabled. For test purposes, I'm using the available sunrain theme.
I've placed the sunrain theme manually inside the /resources folder, as suggested per
http://developer.plone.org/reference_manuals/external/plone.app.theming/userguide.html#deploying-and-testing-themes
Trying to enable that theme in the Site Setup | Theming panel | Advanced, I set the path to the theme rules to
/++theme++sunrain/rules.xml
and the absolute path prefix to
/++theme++sunrain/
Plone does not recognize it: no theme gets enabled. The debug mode spits out the following error codes
2014-03-29 00:10:07 ERROR plone.subrequest Error handling subrequest to /++theme++sunrain/rules.xml
Traceback (most recent call last):
File "/home/plone/Plone/buildout-cache/eggs/plone.subrequest-1.6.7-py2.7.egg/plone/subrequest/__init__.py", line 116, in subrequest
traversed = request.traverse(path)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.21-py2.7.egg/ZPublisher/BaseRequest.py", line 502, in traverse
subobject = self.traverseName(object, entry_name)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.21-py2.7.egg/ZPublisher/BaseRequest.py", line 326, in traverseName
ob2 = namespaceLookup(ns, nm, ob, self)
File "/home/plone/Plone/buildout-cache/eggs/zope.traversing-3.13.2-py2.7.egg/zope/traversing/namespace.py", line 112, in namespaceLookup
return traverser.traverse(name, ())
File "/home/plone/Plone/buildout-cache/eggs/plone.resource-1.0.2-py2.7.egg/plone/resource/traversal.py", line 27, in traverse
raise NotFound
NotFound
2014-03-29 00:10:07 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
File "/home/plone/Plone/buildout-cache/eggs/plone.transformchain-1.0.3-py2.7.egg/plone/transformchain/transformer.py", line 48, in __call__
newResult = handler.transformIterable(result, encoding)
File "/home/plone/Plone/buildout-cache/eggs/plone.app.theming-1.1.1-py2.7.egg/plone/app/theming/transform.py", line 170, in transformIterable
transform = self.setupTransform(runtrace=runtrace)
File "/home/plone/Plone/buildout-cache/eggs/plone.app.theming-1.1.1-py2.7.egg/plone/app/theming/transform.py", line 108, in setupTransform
transform = compileThemeTransform(rules, absolutePrefix, readNetwork, parameterExpressions, runtrace=runtrace)
File "/home/plone/Plone/buildout-cache/eggs/plone.app.theming-1.1.1-py2.7.egg/plone/app/theming/utils.py", line 580, in compileThemeTransform
runtrace=runtrace,
File "/home/plone/Plone/buildout-cache/eggs/diazo-1.0.4-py2.7.egg/diazo/compiler.py", line 115, in compile_theme
read_network=read_network,
File "/home/plone/Plone/buildout-cache/eggs/diazo-1.0.4-py2.7.egg/diazo/rules.py", line 195, in process_rules
rules_doc = etree.parse(rules, parser=rules_parser)
File "lxml.etree.pyx", line 2957, in lxml.etree.parse (src/lxml/lxml.etree.c:56299)
File "parser.pxi", line 1526, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:82331)
File "parser.pxi", line 1555, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:82624)
File "parser.pxi", line 1455, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:81663)
File "parser.pxi", line 1002, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:78623)
File "parser.pxi", line 569, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:74567)
File "parser.pxi", line 650, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:75458)
File "parser.pxi", line 588, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:74760)
IOError: Error reading file '/++theme++sunrain/rules.xml': failed to load external entity "/++theme++sunrain/rules.xml"
What's wrong here?
ps: of course I can upload the theme as zip file and enable it that way, which works fine. I would really like to edit through-the-filesystem as I can foresee a lot of development in the future.
An up-to-date and working write-up for plone432 how to edit diazo themes through the filesystem using the /resources directory would be the answer, but I have not found that either outside of the plone.app.theming user guide. Help!

plone.outputfilters.filters.resolveuid_and_caption: got an unexpected keyword argument 'quote'

I have started to see this on old 3.3.x instance:
'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0x1153346c>}
Module zope.tales.expressions, line 217, in __call__
Module Products.PageTemplates.Expressions, line 163, in _eval
Module Products.PageTemplates.Expressions, line 125, in render
Module Products.Archetypes.ClassGen, line 56, in generatedAccessor
Module wicked.fieldevent, line 29, in render
Module zope.event, line 23, in notify
Module zope.component.event, line 26, in dispatch
Module zope.component._api, line 130, in subscribers
Module zope.component.registry, line 290, in subscribers
Module zope.interface.adapter, line 583, in subscribers
Module wicked.fieldevent, line 16, in notifyFieldEvent
Module zope.component._api, line 101, in getMultiAdapter
Module zope.component._api, line 114, in queryMultiAdapter
Module zope.component.registry, line 206, in queryMultiAdapter
Module zope.interface.adapter, line 530, in queryMultiAdapter
Module wicked.fieldevent.meta, line 78, in field_value
Module Products.Archetypes.Field, line 1394, in get
Module Products.Archetypes.BaseUnit, line 100, in transform
Module Products.PortalTransforms.TransformEngine, line 181, in convertTo
Module Products.PortalTransforms.chain, line 51, in convert
Module Products.PortalTransforms.Transform, line 192, in convert
Module plone.outputfilters.transforms.html_to_plone_outputfilters_html, line 47, in convert
Module plone.outputfilters, line 6, in apply_filters
Module plone.outputfilters.filters.resolveuid_and_caption, line 103, in __call__
Module sgmllib, line 95, in feed
Module sgmllib, line 129, in goahead
Module sgmllib, line 283, in parse_starttag
Module sgmllib, line 314, in finish_starttag
Module plone.outputfilters.filters.resolveuid_and_caption, line 349, in unknown_starttag
TypeError: <lambda>() got an unexpected keyword argument 'quote'
It apparently some kind of compatibility problem with Plone 3.3.x and plone.outputfilters which could be solved with proper pindowns. However I am not sure what components are involved and thus what's Known Good Set to fix this.
I'd like to get a temporary solution for this before getting all sites migrated, as old stuff should not just break down if you leave it unattended :(
Also the latest security fix might be involved.
I too have a few old 3.3.5 sites and just started seeing this error. Pinning plone.outputfilters to version 1.6 seems to fix it so far. I.e., in buildout.cfg
[versions]
...
plone.outputfilters = 1.6
I bet you are using TinyMCE, this pulls p.outputfilters.
As with the Plone-3-series the default editor is Kupu, this changement can be the cause and apparently has been fixed in the Plone-core: https://dev.plone.org/ticket/9938
Quoting David Glick:
"For historical reasons, these transformations are implemented in both kupu and TinyMCE. This has been a maintenance problem, as bugfixes for these features in one of the packages usually don't get ported to the other."
You'll have to apply a patch according to these changements, I suppose.
Also this changement could be relevant as this topic concerns both, the core and the third-party-editor code:
https://github.com/plone/plone.outputfilters/commit/e5067c8ef1894d1017d6bc81c5969112676840d5#plone/outputfilters/filters/resolveuid_and_caption.py
Using the current unreleased dev-branch of p.outputfilters (1.9 by time of writing) could help, too.

Folders don't show up in navigation, KeyError while editing them

Recently we noticed that some (published) folders in our Plone 3.3.5 site are no longer visible in the navigation and folder listing views. While trying to set a new effective date (it's set in the past, so that is not the problem) on them i get a KeyError:
Traceback (innermost last):
Module ZPublisher.Publish, line 125, in publish
Module Zope2.App.startup, line 238, in commit
Module transaction._manager, line 96, in commit
Module transaction._transaction, line 389, in commit
Module transaction._transaction, line 445, in _callBeforeCommitHooks
Module collective.indexing.transactions, line 57, in before_commit
Module collective.indexing.queue, line 149, in process
Module collective.indexing.indexer, line 89, in unindex
Module collective.indexing.indexer, line 71, in unindex
Module Products.CMFSquidTool.queue, line 160, in unindexObject
Module Products.CMFSquidTool.patch, line 24, in call
Module Products.Archetypes.CatalogMultiplex, line 49, in unindexObject
Module Products.CMFPlone.CatalogTool, line 445, in uncatalog_object
Module Products.CacheSetup.patch, line 109, in uncatalog_object
Module Products.CacheSetup.patch_utils, line 6, in call
Module Products.ZCatalog.ZCatalog, line 569, in uncatalog_object
Module Products.ZCatalog.Catalog, line 390, in uncatalogObject
Module Products.PluginIndexes.DateRangeIndex.DateRangeIndex, line 192, in unindex_object
Module Products.PluginIndexes.DateRangeIndex.DateRangeIndex, line 391, in _removeForwardIndexEntry
KeyError: -1666126693
In some cases other operations also triggers the same errors.
The parent folder in which this is happening was recently cut and pasted to its current location in the site, maybe that's got something to do with it.
Help much appreciated, thanks !
Try to rebuild the catalog, it can help, it seems there are some orphan objects in the catalog.

Resources