Skip to content

DLL import error when installing PIL in custom directory and then importing #7172

@mai1x9

Description

@mai1x9

PIL version: 9.4.0
OS: Windows 10.

I have installed PIL in custom directory named contrib, using

pip install PIL-t ./contrib

And from test.py which is outside contrib directory, I have imported as shown below by adding contrib to sys path.

import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "contrib" ))
from PIL import Image
# from contrib.PIL import Image
im = Image.open(r"image.jpg") 
  
# This method will show image in any image viewer 
im.show()

and it throws the error.

Traceback (most recent call last):
  File ".\test.py", line 15, in <module>
    from PIL import Image
  File ".\contrib\PIL\Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The parameter is incorrect.

Even below import throws error.

from contrib.PIL import Image
import contrib.PIL.Image

However, it is working when it is installed in default location lib. Am i missing something like adding dll part in windows or something like that??

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions