本文介绍了python-使用pickle.load()时没有名为dill的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python 2.7中安装了莳萝,但是当我尝试解开模型时,它说没有名为莳萝的模块".腌制后的文件包含熊猫系列.

I have dill installed in my python 2.7 but when I try to unpickle my model it says "No module named dill". The pickled file contains pandas series.

这是ElasticBeanstalk环境中的回溯快照

EDIT :Here's the snapshot of the traceback on ElasticBeanstalk environment

File "/opt/python/current/app/app/models/classification.py", line 663, in __init__
  self.lookupdict = pickle.load(open(<filepath>))
File "/usr/lib64/python2.7/pickle.py", line 1384, in load
  return Unpickler(file).load()
File "/usr/lib64/python2.7/pickle.py", line 864, in load
  dispatch[key](self)
File "/usr/lib64/python2.7/pickle.py", line 1096, in load_global
  klass = self.find_class(module, name)
File "/usr/lib64/python2.7/pickle.py", line 1130, in find_class
  __import__(module)
File "/opt/python/run/venv/local/lib64/python2.7/site-packages/gevent/builtins.py", line 93, in __import__
  result = _import(*args, **kwargs)
ImportError: No module named dill

推荐答案

如果Elastic beantalk或错误环境上的版本大于本地版本,则将莳萝包降级为可在EC2或本地计算机上使用的包.在本地计算机上,检查当前的莳萝包:

If version on your Elastic beanstalk or error environment is greater than your local version then downgrade your dill package to the package which is working on your EC2 or local machine.On your local machine, check current dill package:

pip freeze | grep -i 'dill'

例如,它输出:dill == 0.2.7.1,该值低于beantalk上的值

e.g it outputs: dill==0.2.7.1 which is lower than what it is on beanstalk

然后使用降级

pip install dill==0.2.7.1

这篇关于python-使用pickle.load()时没有名为dill的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 01:45