question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pyvips in Docker environment

See original GitHub issue

Hi there, This issue is related with #76 .

I’ll borrow my previous comments in #76 in below.


Hello @jcupitt , I’m using docker environment and python 3.7. I think I’m suffering similar issues. Can I get a any hint for this issue?

~$ docker exec -it 2b14 /bin/bash
root@2b147d09f5d5:/conduit# pip3.7 install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python3.7/site-packages (19.0.1)
root@2b147d09f5d5:/conduit# pip3.7 install pyvips
Requirement already satisfied: pyvips in /usr/local/lib/python3.7/site-packages (2.1.5)
Requirement already satisfied: cffi>=1.0.0 in /usr/local/lib/python3.7/site-packages (from pyvips) (1.11.5)
Requirement already satisfied: pycparser in /usr/local/lib/python3.7/site-packages (from cffi>=1.0.0->pyvips) (2.19)
root@2b147d09f5d5:/conduit#  python3.7
Python 3.7.2 (default, Jan 23 2019, 02:31:57) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyvips/__init__.py", line 19, in <module>
    import _libvips
ModuleNotFoundError: No module named '_libvips'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pyvips/__init__.py", line 69, in <module>
    vips_lib = ffi.dlopen(_vips_libname)
  File "/usr/local/lib/python3.7/site-packages/cffi/api.py", line 141, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/usr/local/lib/python3.7/site-packages/cffi/api.py", line 802, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/usr/local/lib/python3.7/site-packages/cffi/api.py", line 797, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libvips.so.42'

https://github.com/libvips/pyvips/issues/76#issuecomment-459685994 @jcupitt commented Have you installed the libvips library? It looks like it can’t be found by pyvips. If you can’t fix it, please open a new issue and share your Dockerfile.


I think I don’t have libvips in docker environment as you told. Though I want to download a libvips in docker env, I can not find easy and precise way. I downloaded libvips in my local linux(ubuntu) env with just command apt install libvips-tools.

So, Can you please let me know the precise way to download libvips library in docker environment?

By the way, Its my Dockerfile

 FROM python:3
 ENV PYTHONUNBUFFERED 1
 RUN mkdir /backend
 WORKDIR /backend
 ADD requirements.txt /backend/
 RUN pip install -r requirements.txt
 ADD . /backend/
 EXPOSE 8000

and requirements.txt

Django==1.9.6
django-extensions==1.6.7
djangorestframework==3.3.3
PyJWT==1.4.0
six==1.10.0
django-cors-headers
psycopg2

Also using docker-compose

  backend:
    build: .
    volumes:
      - ./:/conduit 
    working_dir: /conduit/
    command: sh entrypoint.sh
    ports:
      - 8000:8000
    depends_on:
      - db

and entrypoint.sh

pip install -r requirements.txt
python manage.py migrate
python manage.py runserver 0.0.0.0:8000

Sorry for my broken english.

Sincerely, Eunsung Sam Koh

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
EunsungKohcommented, Feb 8, 2019

Finally It works!

root@837287600fd5:/conduit# python3
Python 3.7.2 (default, Feb  6 2019, 12:04:03) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.basicConfig(level = logging.DEBUG)
>>> import pyvips
DEBUG:pyvips:Loaded binary module _libvips
DEBUG:pyvips:Inited libvips
>>> 

THANKS @jcupitt 👍

1reaction
jcupittcommented, Feb 7, 2019

Yes, works for me too. I made you a complete Dockerfile:

https://github.com/jcupitt/docker-builds/tree/master/pyvips-python3

I see:

$ docker build -t pyvips-python3 .
Sending build context to Docker daemon  15.87kB
...
Successfully built pyvips pycparser
Installing collected packages: pycparser, cffi, pyvips
Successfully installed cffi-1.11.5 pycparser-2.19 pyvips-2.1.5
Removing intermediate container 10237d85e203
 ---> 39e76254370f
Successfully built 39e76254370f
Successfully tagged pyvips-python3:latest

Then:

$ docker run --rm -it pyvips-python3
Python 3.7.2 (default, Feb  6 2019, 12:04:03) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Installation — dicom-wsi 0.1.0 documentation
If you don't have pip installed, this Python installation guide can guide you through the process. From sources¶. The sources for dicom-wsi can...
Read more >
Image processing with libvips — pyvips 2.2.1 documentation
pyvips – Image processing with libvips¶. Contents¶. README · How it works · conda Install · Non-conda install · Example · Notes.
Read more >
Azure Machine Learning Curated Environments
They are backed by cached Docker images that use the latest version of the Azure Machine Learning SDK, reducing the run preparation cost...
Read more >
Search: libvips - Sudo null
How to Setup Pyvips (Libvips) 2.1.12 Environment for Python on. ... Installs libvips in an Alpine Linux Docker image using the vips-tools apk....
Read more >
Python Binding for Libvips using Cffi - Morioh
You will also need to add vips-dev-x.y\bin to your PATH so that pyvips can find all the ... If you set the PATH...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found