chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
809 stars 131 forks source link

Error in importing saved SVM model using joblib #179

Closed Raghu17s closed 4 years ago

Raghu17s commented 4 years ago

Hi,

I am trying to import the saved SVM model into app. But, its throwing error when I use "from sklearn.externals import joblib". The error says to import joblib directly, but such a library is not listed in https://chaquo.com/pypi-2.1/ repository.

My code is: install "scikit-learn" from sklearn.externals import joblib

The error is:

/data/user/0/com.chaquo.python.console/files/chaquopy/AssetFinder/requirements/sklearn/externals/joblib/init.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.

mhsmith commented 4 years ago

That looks like a warning, not an error, so you might just be able to ignore it. However, if you do want to install joblib separately, then simply add install "joblib" to your build.gradle file. Joblib is a pure-Python package, so it doesn't need to be in our repository.

You may need to use the workaround from https://github.com/joblib/joblib/issues/825.

Raghu17s commented 4 years ago

I have used following code. install "joblib" import joblib

But still, it throws this error.

/data/user/0/com.chaquo.python.console/files/chaquopy/AssetFinder/requirements/joblib/_multiprocessing_helpers.py:53: UserWarning: [Errno 38] Function not implemented. joblib will operate in serial mode Exception in thread Thread-1: Traceback (most recent call last): File "stdlib/threading.py", line 916, in _bootstrap_inner File "stdlib/threading.py", line 864, in run File "/data/user/0/com.chaquo.python.console/files/chaquopy/AssetFinder/app/chaquopy/utils/console.py", line 14, in File "class.pxi", line 695, in java.chaquopy.JavaMethod.get.lambda2 File "class.pxi", line 715, in java.chaquopy.JavaMethod.call File "class.pxi", line 805, in java.chaquopy.JavaMethod.call_nonvirtual_method File "env.pxi", line 242, in java.chaquopy.CQPEnv.CallNonvirtualVoidMethodA File "env.pxi", line 484, in java.chaquopy.CQPEnv.check_exception com.chaquo.python.PyException: ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770. at .multiprocessing.synchronize.(synchronize.py:34) at .java.chaquopy.import_override(import.pxi:60) at .joblib.externals.loky.backend.(init.py:13) at .java.chaquopy.import_override(import.pxi:60) at .joblib.externals.loky.(init.py:11) at .java.chaquopy.import_override(import.pxi:60) at .joblib.parallel.(parallel.py:31) at .java.chaquopy.import_override(import.pxi:60) at .joblib.(init.py:120) at .java.chaquopy.import_override(import.pxi:60) at .main.(main.py:6) at .importlib._bootstrap._call_with_frames_removed(:219) at .importlib._bootstrap_external.exec_module(:678) at .java.android.importer.exec_module(importer.py:346) at .importlib._bootstrap._load_unlocked(:665) at .importlib._bootstrap._find_and_load_unlocked(:955) at .importlib._bootstrap._find_and_load(:971) at .importlib._bootstrap._gcd_import(:994) at .importlib.import_module(init.py:126) at .chaquopy_java.Java_com_chaquo_python_Python_getModule(chaquopy_java.pyx:154) at com.chaquo.python.Python.getModule(Native Method) at com.chaquo.python.console.MainActivity$Task.run(MainActivity.java:18) at com.chaquo.python.utils.ConsoleActivity$Task$1.run(ConsoleActivity.java:352)

mhsmith commented 4 years ago

As I said before, use the workaround from joblib/joblib#825.

Raghu17s commented 4 years ago

Great!, its working

mhsmith commented 4 years ago

If you're using Chaquopy 8.0.1 or later, there's no longer any need to use the workaround above, or to use old versions of librosa or joblib.

To upgrade Chaquopy, edit your app's top-level build.gradle file and change the version number of com.chaquo.python:gradle.