anibali / pywebp

Python bindings for WebP
MIT License
74 stars 24 forks source link

ImportError #38

Closed Sibiryakanton closed 1 year ago

Sibiryakanton commented 1 year ago

When I try to use the code with a package in the pipeline, I get an error:

project_name/modules/image_handler.py:6: in <module>
    import webp
/venv/project-env-9TtSrW0h-py3.10/lib/python3.10/site-packages/webp/__init__.py:6: in <module>
    from _webp import ffi, lib
E   ModuleNotFoundError: No module named '_webp'

How can i fix it?

anibali commented 1 year ago

How did you install the webp package, what version did you install, and what platform are you on (Windows/Linux)?

x2a-io commented 1 year ago

Running into this same issue on MacOS (12.6), Python 3.10.10, webp==0.1.5 - with the package installed via pip: pip install -U webp

Here's my error message:

>>> import webp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.10/site-packages/webp/__init__.py", line 6, in <module>
    from _webp import ffi, lib
ModuleNotFoundError: No module named '_webp'
anibali commented 1 year ago

Unfortunately macOS is currently not supported, I've only built wheels for Windows and Linux. In theory it should be able to build from the source distribution, but it looks like that is not working based on your results.

Since I don't have access to Apple hardware it is difficult for me to provide support, but I can try to see if I can build a wheel for macOS and hopefully it just works. I'll give that a go and let you know.

x2a-io commented 1 year ago

Ah, I see thanks! I could swear it was working in the past... just not sure how many versions ago though. I'll try and build on my end - but also happy to test whatever ones you build.

x2a-io commented 1 year ago

Everything works fine with webp==0.1.4. It seems something changed with 0.1.5

Sibiryakanton commented 1 year ago
  1. poetry add webp
  2. webp = "^0.1.5"
  3. Ubuntu 20.04.5 LTS
anibali commented 1 year ago

The issue is that installing from the sdist (source tarball) is broken, and this affects all platforms. It seems that the problem started after I moved the project to Poetry. I need to fix the sdist, and then as a bonus I will provide wheels so that it's faster to install on macOS in the future.

Sibiryakanton commented 1 year ago

With 0.1.4 i got the other error in lambda: https://pastebin.com/zkMew4qf

Gone if switched to 0.1.5

anibali commented 1 year ago

That was quite a nasty issue to get to the bottom of. It seems like the root cause was a change in Poetry related to build scripts, which broke builds from the sdist tarball: https://github.com/python-poetry/poetry/issues/2740

I've now released a new version, 0.1.6, which should fix the problem. Please give that a go and let me know if it works for you.

Sibiryakanton commented 1 year ago

Yep, it works, you are brilliant human being. :)