PicklingError while Installing add-on - portlet

I was given the task of upgrading a plone site from 3.1.7 to 4.0.3. I've successfully gotten the site upgraded, but now I'm trying to install collective.lineage and I get the following error:
Traceback (innermost last):
Module ZPublisher.Publish, line 135, in publish
Module Zope2.App.startup, line 291, in commit
Module transaction._manager, line 93, in commit
Module transaction._transaction, line 322, in commit
Module transaction._transaction, line 416, in _commitResources
Module ZODB.Connection, line 558, in commit
Module ZODB.Connection, line 606, in _commit
Module ZODB.Connection, line 640, in _store_objects
Module ZODB.serialize, line 422, in serialize
Module ZODB.serialize, line 431, in _dump
PicklingError: Can't pickle <class 'quills.app.portlets.quillslinks.IQuillsLinksPortlet'>: import of module quills.app.portlets.quillslinks failed
Quills was installed before the upgrade, but wasn't being utilized on the site so I uninstalled it while the site was still a 3.1.7 via the quickinstaller (I don't believe quills has an uninstall profile).
Additionally, this error doesn't effect all add-on's, i installed collective.redirect yesterday without incident.
Obviously Quills didn't uninstall cleanly, but honestly don't know where to start when fixing this.
Any help would be greatly appreciated.

It looks to me like Quills assigned some portlets somewhere that were not unassigned when Quills was removed.
The best solution would be to remove those portlets before removing Quills. Unfortunately, I'm not aware of a tool to get an overview of where portlets are assigned and identify at a glance where the offending portlet is so that you can remove it. Maybe someone else knows of such a tool?
You could try exporting the portlet configuration using the portal_setup tool; the resulting portlets.xml might include information on where this portlet or portlets are assigned.
Or instead of locating and removing the portlets, you could try registering a dummy replacement of the interface that's breaking (this should go in the initialization code of some product in your instance):
import imp, sys
from zope.interface import Interface
m = imp.new_module('quills.app.portlets.quillslinks')
sys.modules['quills.app.portlets.quillslinks'] = m
m.IQuillsLinksPortlet = Interface
That last solution should be considered an ugly hack, though.

Related

Distributing pybind11 extension linked to third party libraries

I'm working on a pybind11 extension written in C++ but I'm having a hard time understanding how should it be distributed.
The project links to a number of third party libraries (e.g. libpng, glew etc.).
The project builds fine with CMAKE and it generates a .so file. Now I am not sure what is the right way of installing this extension. The extension seems to work, as if I try copy the file into the python lib directories it is picked up (I can import it, and it works correctly). However, this is clearly not the way to go I think.
I also tried the setuptools route (from https://pybind11.readthedocs.io/en/stable/compiling.html) by creating a setup.py files like this:
import sys
# Available at setup time due to pyproject.toml
from pybind11 import get_cmake_dir
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
from glob import glob
files = sorted(glob("*.cpp"))
__version__ = "0.0.1"
ext_modules = [
Pybind11Extension("mylib",
files,
# Example: passing in the version to the compiled code
define_macros = [('VERSION_INFO', __version__)],
),
]
setup(
name="mylib",
version=__version__,
author="fab",
author_email="fab#fab",
url="https://github.com/pybind/python_example",
description="mylib",
long_description="",
ext_modules=ext_modules,
extras_require={"test": "pytest"},
cmdclass={"build_ext": build_ext},
zip_safe=False,
python_requires=">=3.7",
)
and now I can build the extension by simply calling
pip3 install
however it looks like all the links are broken because whenever I try importing the extension in Python I get linkage errors, as if setuptools does not link correctly the extension with the 3rd party libs. For instance errors in linking with libpng as in:
>>> import mylib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/fabrizio/.local/lib/python3.8/site-packages/mylib.cpython-38-x86_64-linux-gnu.so: undefined symbol: png_sig_cmp
However I have no clue how to add this link info to setuptools, and don't even know if that's possible (it should be the setuptools equivalent of CMAKE's target_link_libraries).
I am really at a loss after weeks of reading documentation, forum threads and failed attempts. If anyone is able to point me in the right way or to clear some of the fog it would be really appreciated!
Thanks!
Fab
/home/fabrizio/.local/lib/python3.8/site-packages/mylib.cpython-38-x86_64-linux-gnu.so: undefined symbol: png_sig_cmp
This line pretty much says it clearly. Your local shared object file .so can't find the libpng.so against which it is linked.
You can confirm this by running:
ldd /home/fabrizio/.local/lib/python3.8/site-packages/mylib.cpython-38-x86_64-linux-gnu.so
There is no equivalent of target_link_libraries() in setuptools. Because that wouldn't make any sense. The library is already built and you've already linked it. This is your system more or less telling you that it can't find the libraries it needs. And those most likely need to be installed.
This is also one of the reasons why Linux distributions provide their own package managers and why you should use the developer packages provided by said distributions.
So how do you fix this? Well your .so file needs to find the other .so files against which you linked to understand how this works I will refer you to this link.
My main guess is based on the fact that when you manually copy the files it works - That during the build process you probably specify the rpath to a local directory. Hence what you most likely need to do is specify to your setuptools that it needs to copy those files when installing.

ModuleNotFoundError: No module named 'windows'

I'm working on a project and I need to use the PyMouse module.
pip install pymouse
installed pymouse correctly, so I assumed all was fine.
However, when importing PyMouse:
from pymouse import PyMouse
I got the following error running my program:
Traceback (most recent call last):
File "4opeenrij.py", line 1, in <module>
from pymouse import PyMouseEvent
File "C:\Users\lcdew\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymouse\__init__.py", line 92, in <module>
from windows import PyMouse, PyMouseEvent
ModuleNotFoundError: No module named 'windows'
I can't seem to figure out what might cause this error message. Any help would be much appreciated.
Additional info:
I'm using Python 3.7 32 bit
Current pip version: 18.1
I have Windows 10
working on a 64-bit operating system
I had I look into this and became puzzled at first, so looked deeper.
It turns out that pymouse is absolutely full of errors. More that I bothered to find.
The error you got is just one of many errors caused by bad coding.
The code says:
from windows import PyMouse, PyMouseEvent
And it should say:
from .windows import PyMouse, PyMouseEvent
Also, PyUserInput, a sister package that is free from the pymouse errors, requires pyhook, which is unsupported by python 3. After a lot of looking around, the conclusion that there is no way around the problems found, except maybe installing a really early version.
You could also try the keyboard module.
You might want to take a look at pynput module. It works on python 3.8, doesn't have any incompatible dependencies, and doesn't seem to have any errors. Once you have the module installed, this page gives some good examples of various ways to manage the mouse.

Cannot import Tensorflow with Eclipse on Ubuntu16.04

The bug happens when I try to import Tensorflow on Eclipse. Tensorflow can
be imported when I directly run the python code without using IDEs (I test it and it works perfectly). I've also tested my codes on PyCharm, it's fine with Pycharm....
I've tested the LD_LIBRARY_PATH,PATH,CUDA_HOME variables with echo. I also tried to directly append the cuda libraries into the Ecplipse pydev interpreter setting. So it is really confusing me. I did face a similar question with another machine, but I solved it by modifying the ~/.bashrc file.
I'm using Ubuntu16.04, python2.7,eclipse Neon3, GTX1080ti.
Any ideas? Following is the bug information:
Traceback (most recent call last): File "/home/zernmern/workspace/test/p1/test.py", line 2, in <module>
import tensorflow as tf
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
Please let me know if more information is needed xD.
Ubuntu 16.04 uses Python 3.5 as the default system version of Python. You say that you are using Python 2.7. Did you install that yourself? It doesn't come with the OS. (And if you don't have a compelling reason to stay with Python 2.7, I would encourage you to switch to Py 3.x anyway, especially since you're working with a cutting-edge package like TensorFlow.)
Once you have two versions of Python on your system, it's easy to lose track of which packages you installed to which version of Python. I would check to see whether you happen to have installed TensorFlow, or parts of it, to the system Python 3.5 instead of your Python 2.7.
Finally, I find the solution from 'PyCharm cannot find library'
As the user 'Laizer' suggested:
The issue is that PyCharm(Here is Eclipse) was invoked from the desktop, and wasn't getting the right environment variables. Solution is to either:
invoke from the command line(i.e. Directly start eclipse by sh),
create a script to set environment and then invoke, and make a link to that script on the desktop,
or set environment variables on the desktop item

Importing an old Plone 3.3 site as second site in my Plone 4.1

I'm running a Plone 4.1 site, and since we have a second site that has been down for a while, and which was built over Plone 3.3, we'd like to import that site as well into our Plone 4.1.
I have already created a separate mount point, but copying the old Data.fs file into the new mount point didn't really work.
What I'd like to do is: grab the Data.fs from the old plone install, move it to a separate mount point (it will be placed in a subfolder now, it was just under var/filestorage before), and port it to v.4.1 in some way.
I've searched various tutorials but didn't find any relevant hint on how to solve this need, anybody could give me some pointers?
thanks!
I'd suggest to:
create a clean plone4 separated environment.
copy the old data.fs to the new env
follow the section "Updating a custom Plone 3 buildout for Plone 4" from the Plone Upgrade Guide
export your upgraded site and import it in your first environment
Thanks a lot Giacomo, i was able to move further through the approach you suggested.
So what I've done was:
create a vanilla test instance matching the target version (4.1)
copy Data.fs and blobstorage folder from the old site to my test instance. (In the meantime I realised the old site was a 4.0, not a 3.3, hence I moved also the whole blobstorage folder, otherwise further export wouldn't have worked).
startup my test instance, and upgrade the storage through the "Upgrade" button on plone startup page
from ZMI, export my site to a zexp file
upload the zexp file into zinstance/var/instance/import on the target platform
enter the ZMI of the target platform, select the folder that i mapped to the mount point for my second site, and there import the zexp file
This last step of importing the zexp fails with the following error:
Error Type: TypeError
Error Value: Blobs are not supported
Troubleshooting Suggestions
The URL may be incorrect.
The parameters passed to this resource may be incorrect.
A resource that this resource relies on may be encountering an error.
Which in the logs corresponds to:
2011-10-05T12:49:27 ERROR Zope.SiteErrorLog 1317811767.860.405425857164 http://localhost:8080/mysecondsite/manage_importObject
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module OFS.ObjectManager, line 619, in manage_importObject
Module OFS.ObjectManager, line 637, 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 181, in _importDuringCommit
Module ZODB.Connection, line 1302, in storeBlob
Module ZODB.Connection, line 1331, in _getBlobPath
Module ZODB.Connection, line 1344, in temporaryDirectory
Module ZODB.blob, line 686, in temporaryDirectory
Module ZODB.blob, line 492, in temp_dir
TypeError: Blobs are not supported
Any clue of how to solve this one?
Thanks!
silvio

Can't install FacultyStaffDirectory on Plone 4.1

I am using Plone 4.1 and FacultyStaffDirectory 3.0. My buildout failed with an error (archetypes.schema < 2.1) so I pinned archetypes.schemaextender = 2.0.3 and I was able to install the FSD 3.0. However, when I try to activate it from the Add-ons page I get the following error:
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 575, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
__traceback_info__: ('FacultyStaffDirectory',)
Module Products.GenericSetup.tool, line 323, in runAllImportStepsFromProfile
__traceback_info__: profile-Products.FacultyStaffDirectory:default
Module Products.GenericSetup.tool, line 1074, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 245, in getSortedImportSteps
Module Products.GenericSetup.tool, line 251, in getImportStepMetadata
Module Products.GenericSetup.registry, line 295, in getStepMetadata
Module Products.GenericSetup.utils, line 104, in _resolveDottedName
__traceback_info__: Products.FacultyStaffDirectory.setuphandlers.unindexFSDTool
Module None, line 3, in <module>
ImportError: cannot import name DEFAULT_POLICIES
Faculty Staff Directory needs to be updated for Plone 4.1. The thing that needs changing is described in Plone's upgrade guide, here: http://plone.org/documentation/manual/upgrade-guide/version/upgrading-plone-4.0-to-4.1/updating-add-on-products-for-plone-4.1/use-generic-setup-for-defining-versioning-policies
At FSD's download page ( http://pypi.python.org/pypi/Products.FacultyStaffDirectory/3.0 ) you will find a contact email for the package authors to request they do this.
We're in the process of updating FacultyStaffDirectory for 4.1. The 3.1 release will remove support for Plone prior to 4.0, so we're taking some time to clean up a lot of the cruft that's accumulated in the templates and setup code. SVN trunk is at http://weblion.psu.edu/svn/weblion/weblion/Products.FacultyStaffDirectory/trunk/ if you're feeling adventurous.