hello,Is it possible to use fuzzywuzzy whith rhino python?
I don’t have a degree in programming, but I learned some knowledge of python from the Internet, but I don’t have a solid foundation, so I don’t know how to install additional libraries in rhino python.
I read fuzzywuzzy’s installation requirements, and know that he needs to use python-Levenshtein and difflib of version 2.7 and above.
I found three versions of them that support 2.7 on pypi.org,
cdifflib · PyPI
python-Levenshtein · PyPI
fuzzywuzzy · PyPI
and installed them according to this tutorial article,
http://wiki.bk.tudelft.nl/toi-pedia/Installing_IronPython_modules_for_Grasshopper
but unfortunately there is no response on the editor
Does anyone know how to do this?
That’s a really cool library - thankyou
It should be possible to use a statically linked copy without the optional python-Levenshtein dependency. I downloaded it and extracted it, and ran IronPython in \dist\fuzzywuzzy-0.18.0
, and was able to simply from fuzzywuzzy import fuzz, process
. I could run the tests in the readme for the follow up: GitHub - seatgeek/thefuzz: Fuzzy String Matching in Python
I added a couple of necessary lines of code, and it seems to run in RhinoPython just fine:
import sys
fw_path = r'C:\...path to fuzzywuzzy...\dist\fuzzywuzzy-0.18.0'
if fw_path not in sys.path:
sys.path.insert(0, fw_path)
from fuzzywuzzy import fuzz, process
choices = ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"]
print(process.extract("new york jets", choices, limit=2))
python-Levenshtein and cdifflib have C code, so all bets are off running them in IronPython. Fortunately they’re not necessary (difflib is a core library). And Fuzzywuzzy is a pure python module.
By the way, you’re not supposed to mess around with sys.path in your normal C python code - set PYTHON_PATH instead (or install your deps in a venv). But we don’t have access to Rhino’s IronPython runtime (or its pip), so needs must.
1 Like
oh my god,you are so amazing, I will try it tomorrow, you really helped me a lot, by the way, this library was told to me by chatGPT after I asked for it
1 Like