When I want to import a module X, I can call
using PythonCall
pyimport("X")
I want to import Image
from PIL
, which in python is done by
from PIL import Image
However, I can not access Image
from PIL
directly:
>>> import PIL
>>> PIL.Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'PIL' has no attribute 'Image'
So I need to import them in one statement, or do something else than importing one at a time.
Below is a number of attempts:
julia> PIL = pyimport("PIL")
Python module: <module 'PIL' from '/usr/lib/python3/dist-packages/PIL/__init__.py'>
julia> PIL.Image
ERROR: Python: AttributeError: module 'PIL' has no attribute 'Image'
Python stacktrace: none
Stacktrace:
[1] pythrow()
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/err.jl:94
[2] errcheck
@ ~/.julia/packages/PythonCall/Td3SH/src/err.jl:10 [inlined]
[3] pygetattr(x::Py, k::String)
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/abstract/object.jl:60
[4] getproperty(x::Py, k::Symbol)
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/Py.jl:272
[5] top-level scope
@ REPL[9]:1
julia> PIL = pyimport("from PIL import Image")
ERROR: Python: ModuleNotFoundError: No module named 'from PIL import Image'
Python stacktrace: none
Stacktrace:
[1] pythrow()
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/err.jl:94
[2] errcheck
@ ~/.julia/packages/PythonCall/Td3SH/src/err.jl:10 [inlined]
[3] pyimport(m::String)
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/concrete/import.jl:11
[4] top-level scope
@ REPL[10]:1
julia> PIL = pyimport("PIL"=>"Image")
ERROR: Python: AttributeError: module 'PIL' has no attribute 'Image'
Python stacktrace: none
Stacktrace:
[1] pythrow()
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/err.jl:94
[2] errcheck
@ ~/.julia/packages/PythonCall/Td3SH/src/err.jl:10 [inlined]
[3] pygetattr(x::Py, k::String)
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/abstract/object.jl:60
[4] pyimport(::Pair{String, String})
@ PythonCall ~/.julia/packages/PythonCall/Td3SH/src/concrete/import.jl:12
[5] top-level scope
@ REPL[11]:1
Anyone know how I can import Y
from X
using PythonCall
?