简体   繁体   中英

Can't load Python PIL.Images module using PyCall from Julia

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM