0
votes

In Julia I am using the module PyCall

using PyCall: @pyimport

When I then try to use the scikitlearn library's module called ensamble, there is no problem, it works and I can use the module:

@pyimport sklearn.ensemble as skle

However when I try to do the same with the PIL library or PIL library's module Images, it doesn't work.

@pyimport PIL.Image as PILI

I get the following error: ERROR: PyError (:PyImport_ImportModule) ImportError('No module named PIL.Image',)

[inlined code] from /home/lara/.julia/v0.4/PyCall/src/exception.jl:81 in pyimport at /home/lara/.julia/v0.4/PyCall/src/PyCall.jl:387

Can someone please talk me through the steps to get this working becasue I don't see how this is different from the scikit learn library and ensamble module.

1
can you import in python itself? if not, see e.g. stackoverflow.com/questions/38134362/no-module-named-pilIsaiah Norton
I have used this in Python successfully today yes.lara
Does @pyimport Image work? Otherwise, PyCall might be pointing to a different Python install that doesn't have PIL. Check sys.path in python repl, and compare to @pyimport sys as pysys; pysys.path in Julia. If that's the issue, try github.com/JuliaPy/PyCall.jl#specifying-the-python-versionIsaiah Norton
I have run those two commands but when you say 'compare the two and if that's the issue, try github', what is the comparison supposed to be, just the last part of the directory string? How will I know if I have an issue when comparing the two? For example, the first entry in each is - Python - '/home/lara/anaconda2/lib/python27.zip' and Julia - "/home/lara/.julia/v0.4/Conda/deps/usr/lib/python27.zip"lara

1 Answers

1
votes

Based on discussion in the comments, the issue appears to be that PyCall is using its own Python installation which does not have the requisite library installed. There are two options:

  • follow these instructions to change the Python installation referenced by PyCall to your local one in /home/lara/anaconda2.
  • use Conda.jl to add PIL to the Conda.jl Python install:

    • Conda.add("Pillow") (you could probably use PIL, but Pillow is a compatible fork that is actively maintained from what I can tell)

The second option is probably slightly preferred, but if you have many packages installed already it may be simpler to try the first option (you can always switch back to the Conda.jl version if something doesn't work).