ImportError: cannot import name 'joblib' from 'sklearn.externals'

后端 未结 9 1409
暖寄归人
暖寄归人 2020-12-17 07:59

I am trying to load my saved model from s3 using joblib

import pandas as pd 
import numpy as np
import json
import subprocess
import sqlalchemy
from sklearn.         


        
9条回答
  •  既然无缘
    2020-12-17 08:25

    In case the execution / call to joblib is within another .py program instead of your own (in such case even you have installed joblib, it still causes error from within the calling python programme unless you change the code, i thought would be messy), I tried to create a hardlink:

    (windows version)

    Python> import joblib

    then inside your sklearn path >......\Lib\site-packages\sklearn\externals

    mklink /J ./joblib .....\Lib\site-packages\joblib

    (you can work out the above using a ! or %, !mklink....... or %mklink...... inside your Python juptyter notebook , or use python OS command...)

    This effectively create a virtual folder of joblib within the "externals" folder

    Remarks: Of course to be more version resilient, your code has to check for the version of sklearn is >= 0.23 again before hand.

    This would be alternative to changing sklearn vesrion.

提交回复
热议问题