I have a pyramid application and it has this line
from zope.sqlalchemy import ZopeTransactionExtension
It works without any issues
But if I try the same with command line I get
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sqlalchemy
and
from zope.sqlalchemy.datamanager import ZopeTransactionExtension
ImportError: No module named sqlalchemy.datamanager
I am not really sure why this is so. The docs have the same line and it seems to work for them at least
I recently got the same error in both a pyramid application and the terminal. Reinstalling didn't work in this case. Apparently the zope.sqlalchemy project renamed ZopeTransactionExtension to ZopeTransactionEvents in version 1.2 which was released 2019-10-17.
To make things clearer we renamed the ZopeTransactionExtension class to ZopeTransactionEvents. Existing code using the ‘register’ version stays compatible.
https://pypi.org/project/zope.sqlalchemy/ under Changes 1.2
To fix this, use register
when instantiating the DBSession
from zope.sqlalchemy import register
DBSession = scoped_session(sessionmaker(autoflush=False))
register(DBSession)
According to https://github.com/zopefoundation/zope.sqlalchemy/issues/37
This sounds like an issue with mixing pip and easy_install (which setup.py develop
uses). They do not cooperate well together when it comes to namespaced packages like zope.*
. I suggest recreating your virtualenv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With