简体   繁体   English

sklearn.externals joblib 抛出 ImportError - 服务器上没有名为 joblib.numpy_pickle 的模块

[英]sklearn.externals joblib throws ImportError - no module named joblib.numpy_pickle on a server

I am struggling with a joblib issue.我正在努力解决 joblib 问题。

I need to push inference application to a remote server, and I also need to load a saved standard scaler, because if I try to fit, i get an out of memory exception.我需要将推理应用程序推送到远程服务器,并且我还需要加载一个保存的标准缩放器,因为如果我尝试适应,我会遇到内存不足的异常。 I can't make phisical changes to the server, as it is a sap cloud foundry instance , and I don't see a way to solve it.我无法对服务器进行物理更改,因为它是一个sap Cloud Foundry 实例,而且我没有找到解决它的方法。

Traceback from server:从服务器回溯:

   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR   File "app.py", line 40, in <module>
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR     standard_scaler = joblib.load('./datascaler.save')
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 598, in load
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR     obj = _unpickle(fobj, filename, mmap_mode)
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python2.7/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 526, in _unpickle
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR     obj = unpickler.load()
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python2.7/pickle.py", line 864, in load
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR     dispatch[key](self)
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python2.7/pickle.py", line 1096, in load_global
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR     klass = self.find_class(module, name)
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR   File "/home/vcap/deps/0/python/lib/python2.7/pickle.py", line 1130, in find_class
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR     __import__(module)
   2019-08-05T15:34:41.54+0200 [APP/PROC/WEB/0] ERR ImportError: No module named joblib.numpy_pickle

From what I have seen on similar posts, joblib version conflict/mismatch might be a cause, but I can't really do anything with this, since its not my local machine that has this error.从我在类似帖子中看到的内容来看, joblib 版本冲突/不匹配可能是一个原因,但我对此无能为力,因为它不是我的本地机器出现此错误。

Is there any other way to save the scaler, or to solve this conflict?有没有其他方法可以保存缩放器,或者解决这个冲突?

i also encount this problem.我也遇到这个问题。 there may be two reasons.可能有两个原因。

  1. the mode saved with sklearn.externals.joblib while loading with joblib .在加载sklearn.externals.joblib时使用joblib保存的模式。 (sklearn.externals.joblib and joblib are different libs) (sklearn.externals.joblib 和 joblib 是不同的库)

  2. both sklearn.externals.joblib are used in save and load stage. sklearn.externals.joblib都用于保存和加载阶段。 however, they are different scikit-learn versions.然而,它们是不同的scikit-learn版本。 such as, in save stage scikit-learn==0.19.1 while in load stage scikit-learn==0.21.x .例如,在保存阶段scikit-learn==0.19.1而在加载阶段scikit-learn==0.21.x

the best way to repair it is use joblib with same versions.修复它的最佳方法是使用具有相同版本的 joblib。 sklearn.externals.joblib will be removed in future version. sklearn.externals.joblib 将在未来版本中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM