.pyc file / with_metaclass thing between 0.8/0.9 - needs more detail
After updating SQLAlchemy to 0.9.2 i got this error:
Traceback (most recent call last):
File "/home/vagrant/test/api/app/database/__init__.py", line 1, in <module>
from sqlalchemy import create_engine
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/__init__.py", line 50, in <module>
from .types import (
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/types.py", line 26, in <module>
from . import exc, schema, util, processors, events, event
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 33, in <module>
from . import exc, util, dialects, event, events, inspection
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/event/__init__.py", line 7, in <module>
from .api import CANCEL, NO_RETVAL, listen, listens_for, remove, contains
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/event/api.py", line 13, in <module>
from .base import _registrars
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/event/base.py", line 152, in <module>
class Events(util.with_metaclass(_EventMeta, object)):
AttributeError: 'module' object has no attribute 'with_metaclass'
In version 0.8
class Events(util.with_metaclass(_EventMeta, object))
this existed in multiple files and now in 0.9.2 only in the base.py file so I tried to change it to
class Events(object):
That resulted in:
File "/home/vagrant/shuffler/api/app/database/__init__.py", line 1, in <module>
from sqlalchemy import create_engine
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/__init__.py", line 50, in <module>
from .types import (
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/types.py", line 26, in <module>
from . import exc, schema, util, processors, events, event
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 33, in <module>
from . import exc, util, dialects, event, events, inspection
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/events.py", line 220, in <module>
class SchemaEventTarget(object):
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/events.py", line 227, in SchemaEventTarget
dispatch = event.dispatcher(DDLEvents)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/event/base.py", line 209, in __init__
self.dispatch_cls = events.dispatch
AttributeError: type object 'DDLEvents' has no attribute 'dispatch'
I don't know where to look anymore.
Comments (7)
-
repo owner -
repo owner - changed title to .pyc file / with_metaclass thing between 0.8/0.9 - needs more detail
-
reporter Sorry for the confusing. Today i updated from 0.8.0 (when everything was fine) to 0.9.2. That is when i got the error. Now i've set it back to 0.8.0 just because I knew that was the latest version it was still working on.
So I should just delete all the .pyc files from the sqlalchemy directory?
-
repo owner how are you installing this? SQLA 0.9.2 has the "util.with_metaclass" call, 0.8 does not. you should not get any errors upgrading from 0.8 to 0.9.2. Can you please start with a fresh install of 0.9.2, ensure no .py or .pyc files are present first, then see if 0.9.2 produces an error (and if it does, what is the exact error?)
-
reporter just
sudo pip install SQLAlchemy
Now I uninstalled all versions of SQLAlchemy with:
sudo pip uninstall SQLAlchemy
followed by:
sudo pip install SQLAlchemy # (again)
and now everything is just running smoothly again!
Hmm, there probably went something wrong with the installation the first time when I installed 0.9.2. No idea what it could have been though.
But many thanks for your support!! Now I can finally continue.
-
repo owner - changed status to resolved
alright just going to close this, there's definitely weirdness with .pyc files but typically it shouldnt affect people
-
repo owner - removed milestone
Removing milestone: 0.9.2 (automated comment)
- Log in to comment
OK a little puzzling here is that you're saying the "with_metaclass" thing is in 0.8, which is not the case, that's in 0.9. In 0.8 we have the usual
__metaclass__
attribute.When I switch the files in place from 0.9 to 0.8 I get this error, until the .pyc files are deleted.
So it's a little unclear here if you are in fact going from 0.8 to 0.9, or 0.9 back to 0.8 which is where this is observed, but I think what you need to do is just delete the .pyc files.
if you can confirm this is from 0.9 down to 0.8, not the other way around, I can maybe try to figure out the exact nature of why this happens though people have generally not been reporting it, I think typically using pip/setuptools prevents this kind of thing from happening.