PicklingError: Can't pickle <class 'decimal.Decimal'>: 它与decimal.Decimal 不是同一个对象 [英] PicklingError: Can't pickle <class 'decimal.Decimal'>: it's not the same object as decimal.Decimal

查看:25
本文介绍了PicklingError: Can't pickle <class 'decimal.Decimal'>: 它与decimal.Decimal 不是同一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我今天在 <a href"http://filmaster.com">filmaster.com 上遇到的错误:

<块引用>

PicklingError: Can't pickle :不一样对象为decimal.Decimal

这到底是什么意思?好像没有太大的意义...它似乎与django缓存有关.你可以在这里看到整个回溯:

<块引用>

回溯(最近一次调用):文件/home/filmaster/django-trunk/django/core/handlers/base.py",第 92 行,在 get_response 响应中=回调(请求,*callback_args,**callback_kwargs)文件/home/filmaster/film20/film20/core/film_views.py",第 193 行,在 show_film 中工作流.set_data_for_authenticated_user()文件/home/filmaster/film20/film20/core/film_views.py",第 518 行,在set_data_for_authenticated_userobject_id = self.the_film.parent.id)文件/home/filmaster/film20/film20/core/film_helper.py",第 179 行,在 get_others_ratings 中设置缓存(CACHE_OTHERS_RATINGS,str(object_id) + "_";+ str(user_id),用户评分)文件/home/filmaster/film20/film20/utils/cache_helper.py",第 80 行,在 set_cache 中返回cache.set(CACHE_MIDDLEWARE_KEY_PREFIX+ full_path, result, get_time(cache_string))文件/home/filmaster/django-trunk/django/core/cache/backends/memcached.py",第 37 行,在集合中self._cache.set(smart_str(key), value,超时或 self.default_timeout)文件/usr/lib/python2.5/site-packages/cmemcache.py",第 128 行,在 set val 中,flags =self._convert(val)文件/usr/lib/python2.5/site-packages/cmemcache.py",第 112 行,在 _convert val =pickle.dumps(val, 2)PicklingError: 不能pickle <class'decimal.Decimal'>:不一样对象为decimal.Decimal

Filmmaster 的源代码可以从这里下载:bitbucket.org/filmaster/filmaster-test

任何帮助将不胜感激.

解决方案

我在 jupyter notebook 中运行时遇到此错误.我认为问题在于我使用的是 %load_ext autoreload autoreload 2.重新启动内核并重新运行解决了问题.

This is the error I got today at <a href"http://filmaster.com">filmaster.com:

PicklingError: Can't pickle <class
'decimal.Decimal'>: it's not the same
object as decimal.Decimal

What does that exactly mean? It does not seem to be making a lot of sense... It seems to be connected with django caching. You can see the whole traceback here:

Traceback (most recent call last):

 File
"/home/filmaster/django-trunk/django/core/handlers/base.py",
line 92, in get_response    response =
callback(request, *callback_args,
**callback_kwargs)

 File
"/home/filmaster/film20/film20/core/film_views.py",
line 193, in show_film   
workflow.set_data_for_authenticated_user()

 File
"/home/filmaster/film20/film20/core/film_views.py",
line 518, in
set_data_for_authenticated_user   
object_id = self.the_film.parent.id)

 File
"/home/filmaster/film20/film20/core/film_helper.py",
line 179, in get_others_ratings   
set_cache(CACHE_OTHERS_RATINGS,
str(object_id) + "_" + str(user_id),
userratings)

 File
"/home/filmaster/film20/film20/utils/cache_helper.py",
line 80, in set_cache    return
cache.set(CACHE_MIDDLEWARE_KEY_PREFIX
+ full_path, result, get_time(cache_string))

 File
"/home/filmaster/django-trunk/django/core/cache/backends/memcached.py",
line 37, in set   
self._cache.set(smart_str(key), value,
timeout or self.default_timeout)

 File
"/usr/lib/python2.5/site-packages/cmemcache.py",
line 128, in set    val, flags =
self._convert(val)

 File
"/usr/lib/python2.5/site-packages/cmemcache.py",
line 112, in _convert    val =
pickle.dumps(val, 2)

PicklingError: Can't pickle <class
'decimal.Decimal'>: it's not the same
object as decimal.Decimal

And the source code for Filmaster can be downloaded from here: bitbucket.org/filmaster/filmaster-test

Any help will be greatly appreciated.

解决方案

I got this error when running in an jupyter notebook. I think the problem was that I was using %load_ext autoreload autoreload 2. Restarting my kernel and rerunning solved the problem.

这篇关于PicklingError: Can't pickle &lt;class 'decimal.Decimal'&gt;: 它与decimal.Decimal 不是同一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆