Pyimport() fuzzywuzzy (python module) error

Hi all,

I am new to Julia.

I have been trying to rewrite my Python code in Julia for performance.

For this, I need to import the python module “fuzzywuzzy”. Its a string matching module. I have successfully imported pandas and numpy but not fuzzywuzzy.

using Pkg
ENV["PYTHON"] = "/Users/jithin/opt/anaconda3/bin/python"
Pkg.build("PyCall")

using PyCall
pd = pyimport("pandas")

fuzz = pyimport("fuzzywuzzy")

I get the following error:

PyError (PyImport_ImportModule

The Python package fuzzywuzzy could not be found by pyimport. Usually this means
that you did not install fuzzywuzzy in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package. To install the fuzzywuzzy module, you can
use pyimport_conda("fuzzywuzzy", PKG), where PKG is the Anaconda
package the contains the module fuzzywuzzy, or alternatively you can use the
Conda package directly (via using Conda followed by Conda.add etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python. As explained in the PyCall
documentation, set ENV[“PYTHON”] to the path/name of the python executable
you want to use, run Pkg.build(“PyCall”), and re-launch Julia.

) <class ‘ModuleNotFoundError’>
ModuleNotFoundError(“No module named ‘fuzzywuzzy’”)

Stacktrace:
[1] pyimport(::String) at /Users/jithin/.julia/packages/PyCall/zqDXB/src/PyCall.jl:536
[2] top-level scope at In[39]:1

Not an answer to your question, but if you’re looking to do what fuzzywuzzy does in Julia consider GitHub - matthieugomez/StringDistances.jl: String Distances in Julia

2 Likes

The fact that it says that^ instead of

PyCall is currently configured to use the Python version at:

/Users/jithin/opt/anaconda3/bin/python

means something about your build command must not have worked right. Can you try it again and make sure you restart Julia after building?

1 Like

That is my plan B to this problem, also party inspired from one of your posts here, from '18. However, i just have to know why this doesn’t work. :sweat_smile:
thank you @nilshg :slight_smile:

1 Like

DAMN!!! IT WORKED!

“faith restored” :laughing:

I spent all night banging my head over this! Thank you @marius311 :blush:

1 Like