AttributeError: 'datetime.timezone' object has no attribute '_utcoffset' - python

I have lost ability to plot against datetime object after upgrading of matplotlib.
Error is following:
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2813, in plot
is not None else {}), **kwargs)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/__init__.py", line 1810, in inner
return func(ax, *args, **kwargs)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1611, in plot
for line in self._get_lines(*args, **kwargs):
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 393, in _grab_next_args
yield from self._plot_args(this, kwargs)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 370, in _plot_args
x, y = self._xy_from_xy(x, y)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 204, in _xy_from_xy
bx = self.axes.xaxis.update_units(x)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1475, in update_units
self.set_units(default)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1548, in set_units
self._update_axisinfo()
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1490, in _update_axisinfo
info = self.converter.axisinfo(self.units, self)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pandas/plotting/_converter.py", line 353, in axisinfo
majfmt = PandasAutoDateFormatter(majloc, tz=tz)
File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pandas/plotting/_converter.py", line 367, in __init__
self._tz._utcoffset = self._tz.utcoffset(None)
AttributeError: 'datetime.timezone' object has no attribute '_utcoffset'
Is it possible to upgrade without loosing capabilities in Python?

I think a viable workaround is indicated by this question. Basically, if you convert the pandas timestamps to str and then back to datetime, it magically works.

Related

Dreambooth - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0

I'm trying to train a model via Dreambooth and I'm running into this problem. I've looked for solutions but none of them seem to work. I read adding ".to(device)" to variables helps but I'm not sure where to add them. I was wondering if anyone could tell where to add them by the error below, or if anyone had suggestions on how to fix it. I'm a beginner, so please bear with me.
Traceback (most recent call last):
File "main.py", line 835, in <module>
trainer.fit(model, data)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 741, in fit
self._call_and_handle_interrupt(
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 686, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 778, in _fit_impl
self._run(model, ckpt_path=ckpt_path)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1200, in _run
self._dispatch()
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1280, in _dispatch
self.training_type_plugin.start_training(self)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\plugins\training_type\training_type_plugin.py", line 202, in start_training
self._results = trainer.run_stage()
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1290, in run_stage
return self._run_train()
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1312, in _run_train
self._run_sanity_check(self.lightning_module)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 1376, in _run_sanity_check
self._evaluation_loop.run()
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\loops\base.py", line 145, in run
self.advance(*args, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\loops\dataloader\evaluation_loop.py", line 110, in advance
dl_outputs = self.epoch_loop.run(dataloader, dataloader_idx, dl_max_batches, self.num_dataloaders)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\loops\base.py", line 145, in run
self.advance(*args, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\loops\epoch\evaluation_epoch_loop.py", line 122, in advance
output = self._evaluation_step(batch, batch_idx, dataloader_idx)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\loops\epoch\evaluation_epoch_loop.py", line 217, in _evaluation_step
output = self.trainer.accelerator.validation_step(step_kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\accelerators\accelerator.py", line 236, in validation_step
return self.training_type_plugin.validation_step(*step_kwargs.values())
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\pytorch_lightning\plugins\training_type\training_type_plugin.py", line 219, in validation_step
return self.model.validation_step(*args, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "C:\Dreambooth-SD-optimized\ldm\models\diffusion\ddpm.py", line 368, in validation_step
_, loss_dict_no_ema = self.shared_step(batch)
File "C:\Dreambooth-SD-optimized\ldm\models\diffusion\ddpm.py", line 908, in shared_step
loss = self(x, c)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Dreambooth-SD-optimized\ldm\models\diffusion\ddpm.py", line 937, in forward
c = self.get_learned_conditioning(c)
File "C:\Dreambooth-SD-optimized\ldm\models\diffusion\ddpm.py", line 595, in get_learned_conditioning
c = self.cond_stage_model.encode(c, embedding_manager=self.embedding_manager)
File "C:\Dreambooth-SD-optimized\ldm\modules\encoders\modules.py", line 324, in encode
return self(text, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Dreambooth-SD-optimized\ldm\modules\encoders\modules.py", line 319, in forward
z = self.transformer(input_ids=tokens, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Dreambooth-SD-optimized\ldm\modules\encoders\modules.py", line 297, in transformer_forward
return self.text_model(
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Dreambooth-SD-optimized\ldm\modules\encoders\modules.py", line 258, in text_encoder_forward
hidden_states = self.embeddings(input_ids=input_ids, position_ids=position_ids, embedding_manager=embedding_manager)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Dreambooth-SD-optimized\ldm\modules\encoders\modules.py", line 180, in embedding_forward
inputs_embeds = self.token_embedding(input_ids)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\modules\sparse.py", line 158, in forward
return F.embedding(
File "C:\Users\User\miniconda3\envs\ldm\lib\site-packages\torch\nn\functional.py", line 2044, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)
Any help would be appreciated!
there are a whole bunch of functions in SD that WILL NOT work if you're running --lowvram/--medvram and several of the other command line args. tensors on multiple devices means due to your settings you're at least partially co-processing on your cpu. to test which setting, if you're not sure, don't waste time in dreambooth to troubleshoot, use the textual inversion trainer. it'll trigger the same crash for the same reasons. i have to disable --medvram just to create an embedding, so use that as your troubleshooter. try to create an embedding, change settings, repeat, till you find all the options triggering the cpu/cuda error

Odoo 14 enterprise POS close session error (ProgrammingError: can't adapt type 'res.partner')

when i try to close my session and post entries for my POS,
I had this error :
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo14/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/opt/odoo14/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo14/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo14/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo14/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo14/odoo/http.py", line 912, in call
return self.method(*args, **kw)
File "/opt/odoo14/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/opt/odoo14/addons/web/controllers/main.py", line 1393, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo14/addons/web/controllers/main.py", line 1381, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo14/odoo/api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo14/odoo/api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/opt/odoo14/custom_addons/bi_pos_pay_later/models/pos_session.py", line 35, in action_pos_session_closing_control
session.action_pos_session_close()
File "/opt/odoo14/addons/point_of_sale/models/pos_session.py", line 295, in action_pos_session_close
return self._validate_session()
File "/opt/odoo14/addons/point_of_sale/models/pos_session.py", line 311, in _validate_session
self.with_company(self.company_id)._create_account_move()
File "/opt/odoo14/addons/point_of_sale/models/pos_session.py", line 408, in _create_account_move
data = self._create_invoice_receivable_lines(data)
File "/opt/odoo14/addons/point_of_sale/models/pos_session.py", line 657, in _create_invoice_receivable_lines
receivable_line = MoveLine.create(vals)
File "", line 2, in create
File "/opt/odoo14/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/opt/odoo14/addons/account/models/account_move.py", line 3843, in create
lines = super(AccountMoveLine, self).create(vals_list)
File "", line 2, in create
File "/opt/odoo14/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/opt/odoo14/odoo/addons/base/models/ir_fields.py", line 533, in create
recs = super().create(vals_list)
File "", line 2, in create
File "/opt/odoo14/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/opt/odoo14/odoo/models.py", line 3868, in create
records = self._create(data_list)
File "/opt/odoo14/odoo/models.py", line 3974, in _create
cr.execute(query, params)
File "", line 2, in execute
File "/opt/odoo14/odoo/sql_db.py", line 101, in check
return f(self, *args, **kwargs)
File "/opt/odoo14/odoo/sql_db.py", line 298, in execute
res = self._obj.execute(query, params)
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/odoo14/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo14/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
psycopg2.ProgrammingError: can't adapt type 'res.partner'
this happened especially if some of my POS orders are invoiced ( defined with customers ) How can i solve it ?
i use odoo 14 enterprise hosted on premise.
The shared error log says you use third-party modules like 'bi_pos_pay_later'. Kindly make sure that these modules are not the ones causing errors by creating a new database with these modules and checking the same workflow. If you find that the issue is with the third-party modules, kindly report the same to its developers since they will be better suited to help you.

Iam trying to install a new module in odoo but error occuring, AttributeError: 'str' object has no attribute 'setdefault'

I am trying to use the ODOO server, however I am getting this exception. Seems like a configuraton issue:
Traceback (most recent call last):
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
**AttributeError: 'str' object has no attribute 'setdefault'**
Odoo Server Error
Traceback (most recent call last):
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 913, in __call__
return self.method(*args, **kw)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/http.py", line 532, in response_wrap
response = f(*args, **kw)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/addons/web/controllers/main.py", line 1368, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/addons/web/controllers/main.py", line 1356, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-71>", line 2, in button_immediate_install
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_module.py", line 73, in check_and_log
return method(self, *args, **kwargs)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_module.py", line 474, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/addons/base/models/ir_module.py", line 592, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/loading.py", line 453, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/loading.py", line 346, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/loading.py", line 197, in load_module_graph
registry.setup_models(cr)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/modules/registry.py", line 269, in setup_models
model._setup_base()
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/models.py", line 2780, in _setup_base
self._add_field(name, field.new())
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/models.py", line 402, in _add_field
field.setup_base(self, name)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/fields.py", line 278, in setup_base
self._setup_attrs(model, name)
File "/home/ajay/PycharmProjects/odoo/odoo-14.0/odoo/fields.py", line 2282, in _setup_attrs
ondelete.setdefault(key, 'set null')
Exception
The above exception was the direct cause of the following exception:

auto07p IndexError when uses matplotlib 2.0 instead of matplotlib 1.5

I am recently working on making auto07p work with matplotlib 2.0.
The source code can be found here:
https://sourceforge.net/projects/auto-07p/files/auto07p/0.9/
When using matplotlib 2.0 (or any version greater than 1.5), IndexError: invalid index to scalar variable. appears:
/home/ngb/auto/07p/python/Points.py:1086: VisibleDeprecationWarning: `rank` is deprecated; use the `ndim` attribute or function instead. To find the rank of a matrix see `numpy.linalg.matrix_rank`.
r = rank(array_temp)
Created plot
<graphics.windowPlotter.WindowPlotter2D object at 0x7f9e42007710>
AUTO> Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.5/tkinter/__init__.py", line 1562, in __call__
return self.func(*args)
File "/usr/lib/python3.5/tkinter/__init__.py", line 608, in callit
func(*args)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 370, in idle_draw
self.draw()
File "/home/ngb/auto/07p/python/graphics/grapher_mpl.py", line 92, in draw
self.redraw()
File "/home/ngb/auto/07p/python/graphics/grapher_mpl.py", line 65, in redraw
FigureCanvasTkAgg.draw(self)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 351, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 464, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1143, in draw
renderer, self, dsu, self.suppressComposite)
File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 2409, in draw
mimage._draw_list_compositing_images(renderer, self, dsu)
File "/usr/lib/python3/dist-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 1136, in draw
ticks_to_draw = self._update_ticks(renderer)
File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 969, in _update_ticks
tick_tups = [t for t in self.iter_ticks()]
File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 969, in <listcomp>
tick_tups = [t for t in self.iter_ticks()]
File "/usr/lib/python3/dist-packages/matplotlib/axis.py", line 912, in iter_ticks
majorLocs = self.major.locator()
File "/usr/lib/python3/dist-packages/matplotlib/ticker.py", line 1794, in __call__
return self.tick_values(vmin, vmax)
File "/usr/lib/python3/dist-packages/matplotlib/ticker.py", line 1802, in tick_values
locs = self._raw_ticks(vmin, vmax)
File "/usr/lib/python3/dist-packages/matplotlib/ticker.py", line 1761, in _raw_ticks
istep = np.nonzero(steps >= raw_step)[0][0]
IndexError: invalid index to scalar variable.
It appears that there are only two lines involved. They are from the file /auto/07p/python/graphics/grapher_mpl.py.
The two methods involved are:
def redraw(self):
# recalculate label positions
self.grapher.plotlabels()
FigureCanvasTkAgg.draw(self)
And
def draw(self):
ax = self.grapher.ax
d = {}
if ax is self.grapher.ax3d:
[d["minx"], d["maxx"]] = ax.get_xlim3d()
[d["miny"], d["maxy"]] = ax.get_ylim3d()
[d["minz"], d["maxz"]] = ax.get_zlim3d()
d["azimuth"] = ax.azim
d["elevation"] = ax.elev
d["cur_lims"] = Axes.get_xlim(ax), Axes.get_ylim(ax)
else:
[d["minx"], d["maxx"]] = ax.get_xlim()
[d["miny"], d["maxy"]] = ax.get_ylim()
for k in list(d):
# don't adjust any unchanged settings
if k == "cur_lims":
if map(list, d[k]) == map(list, self.grapher._cur_lims):
del d[k]
elif d[k] == self.grapher.cget(k):
del d[k]
if d != {}:
if "cur_lims" in d:
del d["cur_lims"]
if d != {}:
self.grapher._configNoDraw(**d)
self.redraw()
return
FigureCanvasTkAgg.draw(self)
I would appreciate if anyone can assist me with the error, without changing the matlibplot code but only the auto code. I have read through the code but did not find anything suspicious.
I ran into this error using a given equation and auto file. But if you use matplotlib 2.0 and auto07p to plot most graphs in general, you are very likely to get this error if you zoom on the graph.
I used the files as the following:
https://1drv.ms/f/s!ArJqyyCr1FQOhkITst8JdVK_mIFV
Put them in auto folder.
Run auto.
and type:
auto("couple2.auto")
Thanks.

SQLAlchemy column with enum using PEP 435 compliant enum produces table creation error

I have an enum... defined very similarly to here.
When I try to create a table using the enum, as in the example, I get an error during table creation. It is a very vague error. Here is code that replicates the problem:
from sqlalchemy import Table, MetaData, Column, Enum, create_engine
import enum
class myEnum(enum.Enum):
one = 'one'
two = 'two'
three = 'three'
def main():
e = create_engine('sqlite:///:memory:')
e.echo = True
m = MetaData(bind = e)
t = Table('table', m, Column('my_enum', Enum(myEnum)))
t.create()
if __name__ == '__main__': main()
I get an AttributeError: replace when I run this code, with a seemingly useless stacktrace. I honestly don't even know where to begin debugging this and while I can conceive of a couple of possible workarounds, I am relatively new to SQLAlchemy so I'm not sure what the cleanest solution is. Surely basic enum support is a relatively simple expectation of a ORM framework?
Here is the full stack trace:
Traceback (most recent call last):
File "table_test.py", line 17, in <module>
if __name__ == '__main__': main()
File "table_test.py", line 16, in main
t.create()
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\schema.py", line 725, in create
checkfirst=checkfirst)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1856, in _run_visitor
conn._run_visitor(visitorcallable, element, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1481, in _run_visitor
**kwargs).traverse_single(element)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 121, in traverse_single
return meth(obj, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\ddl.py", line 764, in visit_table
include_foreign_key_constraints=include_foreign_key_constraints
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 914, in execute
return meth(self, multiparams, params)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 962, in _execute_ddl
compiled = ddl.compile(dialect=dialect)
File "<string>", line 1, in <lambda>
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\elements.py", line 494, in compile
return self._compiler(dialect, bind=bind, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\ddl.py", line 26, in _compiler
return dialect.ddl_compiler(dialect, self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 190, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2173, in visit_create_table
create.include_foreign_key_constraints)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2220, in create_table_constraints
for constraint in constraints
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2218, in <genexpr>
p for p in
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2226, in <genexpr>
not getattr(constraint, 'use_alter', False)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 93, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 2369, in visit_check_constraint
literal_binds=True)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 213, in process
return obj._compiler_dispatch(self, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 927, in visit_binary
return self._generate_generic_binary(binary, opstring, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 944, in _generate_generic_binary
binary.right._compiler_dispatch(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 527, in visit_grouping
return "(" + grouping.element._compiler_dispatch(self, **kwargs) + ")"
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 751, in visit_clauselist
for c in clauselist.clauses)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 748, in <genexpr>
s for s in
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 751, in <genexpr>
for c in clauselist.clauses)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 1071, in visit_bindparam
bindparam, within_columns_clause=True, **kwargs)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 1103, in render_literal_bindparam
return self.render_literal_value(value, bindparam.type)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\compiler.py", line 1118, in render_literal_value
return processor(value)
File "C:\Anaconda3\lib\site-packages\sqlalchemy\sql\sqltypes.py", line 171, in process
value = value.replace("'", "''")
File "C:\Anaconda3\lib\enum.py", line 268, in __getattr__
raise AttributeError(name) from None
AttributeError: replace
PEP-435 enum support is being added in 1.1.
1.1.0b1 was recently released. You can upgrade to 1.1.0b1 but be wary of bugs. Based on release history I would say the stable version should be released in a month or two.
how to upgrade:
pip install 'sqlalchemy==1.1.0b3'

Categories

Resources