Forums

Environment path not correct?

Hi so i'm trying to implement a AI into my website as part of my dissertation project, i have my model imported however whenever i attempt to run my program i get the error at the end of this post. This program works fine on my current machine, so my only answer is that the environment path is incorrect.


2021-03-09 16:29:10,591: /usr/lib/python3.7/site-packages/sklearn/base.py:306: UserWarning: Trying to unpickle estimator CountVectorizer from version 0.22.1 when using version 0.21.3. This might lead to breaking code or invalid results. Use at your own risk. 2021-03-09 16:29:10,592: UserWarning) 2021-03-09 16:29:10,597: Exception on /Detected.html [POST] Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/usr/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/usr/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functionsrule.endpoint File "/home/MisinformedOwl/mysite/online.py", line 83, in detected res = Detect(tweet) File "/home/MisinformedOwl/mysite/online.py", line 49, in Detect model = joblib.load(intree) File "/usr/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 595, in load obj = _unpickle(fobj) File "/usr/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 529, in _unpickle obj = unpickler.load() File "/usr/lib/python3.7/pickle.py", line 1088, in load dispatchkey[0] File "/usr/lib/python3.7/pickle.py", line 1376, in load_global klass = self.find_class(module, name) File "/usr/lib/python3.7/pickle.py", line 1426, in find_class import(module, level=0)


ModuleNotFoundError: No module named 'sklearn.tree._classes'


Also, should i be using joblib or pickle to upload this? I've read in research for trying to fix this error that using joblib is better. but ofc it hasn't fixed this

Make sure that you're using the same version of sklearn for pickling and unpickling, because otherwise it's very unlikely to work.