Skip to content

Python: AttributeError: module 'PIL' has no attribute 'PngImagePlugin' #292

Closed
@CarloLucibello

Description

@CarloLucibello

Hi,
I have a problem with my package where I import the pillow module as the PIL variable in the package's init
https://github.com/CarloLucibello/HuggingFaceDatasets.jl/blob/3362f5650483e6ace17e7f2d98af36252d9f4316/src/HuggingFaceDatasets.jl#L43

I run the package's tests

include("test/runtests.jl")

and I get the error

Python: AttributeError: module 'PIL' has no attribute 'PngImagePlugin'
  Python stacktrace: none
  Stacktrace:
    [1] pythrow()
      @ PythonCall ~/.julia/packages/PythonCall/dsECZ/src/err.jl:94
    [2] errcheck
      @ ~/.julia/packages/PythonCall/dsECZ/src/err.jl:10 [inlined]
    [3] pygetattr(x::Py, k::String)
      @ PythonCall ~/.julia/packages/PythonCall/dsECZ/src/abstract/object.jl:60
    [4] getproperty
      @ ~/.julia/packages/PythonCall/dsECZ/src/Py.jl:272 [inlined]
    [5] _pyconvert(x::Py)
      @ HuggingFaceDatasets ~/juliadev/HuggingFaceDatasets/src/transforms.jl:8
    [6] py2jl(x::Py)
      @ HuggingFaceDatasets ~/juliadev/HuggingFaceDatasets/src/transforms.jl:33

The weird thing is that the module actually exists

julia> HuggingFaceDatasets.PIL.PngImagePlugin
Python module: <module 'PIL.PngImagePlugin' from '/home/lucibello/juliadev/HuggingFaceDatasets/.CondaPkg/env/lib/python3.11/site-packages/PIL/PngImagePlugin.py'>

and that when I rum some of the tests individually the error disappears and after that also include("test/runtests.jl") works fine.
Any clue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions