-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fuzzywuzzyR: "attempt to apply non-function" error for all the functions under FuzzMatcher, FuzzExtract and FuzzUtils classes #1
Comments
The fuzzywuzzyR package uses the reticulate package for the R-Python interface. The newer version of the reticulate package (== 0.8) includes a function py_discover_config(required_module = NULL), which shows if a specific module is installed in a python version (i.e. 2.7, 3.5) . For instance, the following appears in my R-session for the fuzzywuzzy module: > reticulate::py_discover_config(required_module = 'fuzzywuzzy')
python: /usr/bin/python3
libpython: /usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5.so
pythonhome: /usr:/usr
version: 3.5.2
numpy: /usr/local/lib/python3.5/dist-packages/numpy
numpy_version: 1.12.1
fuzzywuzzy: /usr/local/lib/python3.5/dist-packages/fuzzywuzzy
python versions found:
/usr/bin/python
/usr/bin/python3
You can do the same for the other two modules, which are necessary for the fuzzywuzzyR package , reticulate::py_discover_config(required_module = 'Levenshtein')
reticulate::py_discover_config(required_module = 'difflib')
That way you can find out if all modules are installed in your default python version. |
@mlampros: Your solution works! Thank you very much. I followed these steps:
Result: matcher$Partial_ratio(string1 = "abcd", string2 = "def") |
I found the same issue when I used fuzzywuzzyR in another system: reticulate::py_discover_config(required_module="fuzzywuzzy") Python directory looks fine, python package is correctly detected. However, matcher <- FuzzMatcher$new() |
The fact is that I built fuzzywuzzyR on a linux OS and I didn't encounter similar errors. However I think that the issues of the reticulate package (or issues of any package that imports the reticulate package - see the 'Reverse imports' or 'Reverse suggests') can be of advantage for you. For instance : https://github.com/statsmaths/kerasR/issues/1 My guess is that you have more than one python 2.7 version on your operating system. |
I'll close the issue for now, hopefully you found a fix in the previously mentioned links. |
Here's a quick fix:
Now check_availability shows TRUE. |
I'm glad you made it work. |
Hello, I am bumping into this is same issue as those above. My check_availability function returns false:
These are my reticulate returns for the Levenshtein and difflib packages: reticulate::py_discover_config(required_module = 'Levenshtein')
python: C:\Python27\ArcGIS10.5\python.exe
libpython: python27.dll
pythonhome: C:\Python27\ArcGIS10.5
version: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
Architecture: 32bit
numpy: C:\Python27\ArcGIS10.5\lib\site-packages\numpy
numpy_version: 1.9.3
Levenshtein: C:\Python27\ArcGIS10.5\lib\site-packages\python_levenshtein-0.12.0-py2.7 win32.egg\Levenshtein
reticulate::py_discover_config(required_module = 'difflib')
python: C:\Python27\ArcGIS10.5\python.exe
libpython: python27.dll
pythonhome: C:\Python27\ArcGIS10.5
version: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
Architecture: 32bit
numpy: C:\Python27\ArcGIS10.5\lib\site-packages\numpy
numpy_version: 1.9.3
difflib: C:\Python27\ArcGIS10.5\lib\difflib.py I can import both of these packages into a Python session, so I am a bit confused as to why R cannot find them. Thanks for your work on this! |
if you tried all the previous suggestions and they do not work for you then probably is something wrong with the python configuration. I faced the same problem in the past when trying to import python modules with the reticulate package. To avoid unistalling and installing python from scratch, I would suggest to also try the following (which in some cases solved the issue for me):
In my OS, for instance, R is located in C:\Program Files\R\R-3.4.0\bin\x64\R. Then, by opening a command prompt (console) and giving (for instance in my case), cd C:\Program Files\R\R-3.4.0\bin\x64\
R
I had access to R console. |
I believe this is the issue as the package cannot locate my python installation, which is located outside of the normal directory due to other software dependencies. Thanks! |
I am still facing this issue, I am running it on MacOs and have used reticulate to point to an existing conda env.
|
hi @karrtikiyer, you use miniconda with which I am not familiar. Would you mind taking a look to the issues of the reticulate package related to miniconda3. There might be related issues to MacOS operating system. |
I reinstalled R and RStudio again, now it works with the above miniconda version. Thanks @mlampros |
I faced the same issue, I installed everything correctly and reticulate showed that fuzzywuzzy etc. was installed and found. However, fuzzywuzzyR would still throw this error. I also noticed, when running Long story short, in order to get the library working I always have to run
I added a pull request to include it in the .onLoad() function. |
I'm running R version 3.3.2 (64-bit), python version 2.7.12 (32-bit) on Windows 8.1 (64-bit). I have installed fuzzywuzzyR as well as corresponding python packages: fuzzywuzzy, Levenshtein
I tried the following:
s1 = ' It was a dark and stormy night. I was all alone sitting on a red chair.'
s2 = ' It was a murky and stormy night. I was all alone sitting on a crimson chair.'
init <- FuzzMatcher$new()
init$Partial_ratio(string1 = s1, string2 = s2)
I received the following error message upon running the last statement:
"Error in init$Ratio(string1 = s1, string2 = s2) :
attempt to apply non-function"
I also observed the following:
check_availability()
[1] FALSE
Is there a fix for this problem? All the online articles showed positive result while testing the functions of FuzzMatcher class.
The text was updated successfully, but these errors were encountered: