Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: _libvips and cffi when importing pyvips #522

Open
H-skyfxxcker opened this issue Mar 6, 2025 · 1 comment
Open

Comments

@H-skyfxxcker
Copy link

Hi,

I'm having trouble importing pyvips after installing it. I get the following error:
Traceback (most recent call last):
File "/root/miniconda3/envs/valisv2/lib/python3.9/site-packages/pyvips/init.py", line 19, in
import _libvips
ModuleNotFoundError: No module named '_libvips'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/root/miniconda3/envs/valisv2/lib/python3.9/site-packages/pyvips/init.py", line 48, in
from cffi import FFI
ModuleNotFoundError: No module named 'cffi'

Problem:
pyvips can't find the _libvips and cffi modules. It seems like the installation isn't linking to libvips and cffi correctly.

@jcupitt
Copy link
Member

jcupitt commented Mar 6, 2025

Hello, I wouldn't use miniconda. Instead, use the python and libvips that come with your dist, make a venv, and pip install pyvips into that. I see:

john@banana ~ $ python3 -m venv ~/vips
john@banana ~ $ . ~/vips/bin/activate
(vips) john@banana ~ $ pip install pyvips
Requirement already satisfied: pyvips in ./vips/lib/python3.12/site-packages (2.2.3)
Requirement already satisfied: cffi>=1.0.0 in ./vips/lib/python3.12/site-packages (from pyvips) (1.17.1)
Requirement already satisfied: pkgconfig in ./vips/lib/python3.12/site-packages (from pyvips) (1.5.5)
Requirement already satisfied: pycparser in ./vips/lib/python3.12/site-packages (from cffi>=1.0.0->pyvips) (2.22)
(vips) john@banana ~ $ python
Python 3.12.7 (main, Feb  4 2025, 14:46:03) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> 

(~/vips is a prefix in my home directory that's on my PATH)

If you have to use miniconda, I'd guess your install has become a bit messed up. Wipe and reinstall your package area. The miniconda docs might have some helpful info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants