libvips / pyvips

python binding for libvips using cffi
MIT License
630 stars 49 forks source link

cannot load library 'libvips-42.dll' #44

Closed Suvi-dha closed 5 years ago

Suvi-dha commented 6 years ago

After trying all the workarounds mentioned in your issues section, I still cannot get rid of this error. Posting the traceback of the error

(base) C:\Users\IIIT\Downloads\vips-dev-w64-all-8.6.3-1\vips-dev-8.6\bin>python Python 3.6.4 |Anaconda custom (64-bit)| (default, Mar 12 2018, 20:20:50) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import pyvips Traceback (most recent call last): File "C:\Users\IIIT\AppData\Roaming\Python\Python36\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 "C:\Users\IIIT\AppData\Roaming\Python\Python36\site-packages\pyvips__init__.py", line 54, in vips_lib = ffi.dlopen(_vips_libname) File "C:\Users\IIIT\Anaconda3\lib\site-packages\cffi\api.py", line 141, in dlopen lib, function_cache = _make_ffi_library(self, name, flags) File "C:\Users\IIIT\Anaconda3\lib\site-packages\cffi\api.py", line 802, in _make_ffi_library backendlib = _load_backend_lib(backend, libname, flags) File "C:\Users\IIIT\Anaconda3\lib\site-packages\cffi\api.py", line 798, in _load_backend_lib return backend.load_library(path, flags) OSError: cannot load library 'libvips-42.dll': error 0x7f

Any other information if needed, please ask.

jcupitt commented 6 years ago

Hello, I have a PC at home now, I'll have a go later.

jcupitt commented 6 years ago

I tried on my win10 PC and it installed OK following the instructions.

  1. Download py 3.6 64-bit from python.org and install, including adding to PATH
  2. Download vips-8.6.3-1 64-bit windows binary, unzip to c:\vips-dev-8.6 (can be anywhere)
  3. Open "Advanced System Settings" and use the Environment Variables button to add c:\vips-dev-8.6\bin to Path.
  4. At a command prompt, verify that running vips works. You may need to log out and in, or even reboot to get the new path value.
  5. At a command prompt, pip install pyvips
  6. Start python and import pyvips works.

Are you using Anaconda? They have their own system and standard pip packages may not work. You should probably ask there for support, or switch to regular python.

jcupitt commented 6 years ago

I revised the README to make this a little clearer.

HackersSpirit commented 6 years ago

Hello, I have followed the same steps as mentioned above but gives me error of libvips-42.dll I tried replacing the dlls from other versions it still gives me error. Many error are related to entry points so i tried replacing the dlls from other versions. As in one of the threads i saw that following functionality would be missing in the given dll file.

Please Note: The only difference which i notice now is i have created a virtual env. But as i can see other modules getting installed correctly this should't create a problem

jcupitt commented 6 years ago

I don't think you can have set your path correctly. Start a command prompt and, without changing directory, type "vips". Do you get some output, or a "command not found" error?

HackersSpirit commented 6 years ago

image

jcupitt commented 6 years ago

I see:

Microsoft Windows [Version 10.0.17134.48]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\jcupi>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\;C:\Users\jcupi\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\jcupi\AppData\Local\Programs\Python\Python36\;C:\Users\jcupi\AppData\Local\Programs\Python\Launcher\;C:\Users\jcupi\AppData\Local\Microsoft\WindowsApps;c:\vips-dev-8.6\bin;

C:\Users\jcupi>vips
Usage:
  vips [OPTIONâ?▌] [ACTION] [OPTIONS] [PARAMETERS] - VIPS driver program

Help Options:
  -h, --help                    Show help options

Application Options:
  -l, --list=BASE-NAME          list objects
  -p, --plugin=PLUGIN           load PLUGIN
  -v, --version                 print version
  --vips-concurrency=N          evaluate with N concurrent threads
  --vips-progress               show progress feedback
  --vips-leak                   leak-check on exit
  --vips-profile                profile and dump timing on exit
  --vips-disc-threshold=N       images larger than N are decompressed to disc
  --vips-novector               disable vectorised versions of operations
  --vips-cache-max=N            cache at most N operations
  --vips-cache-max-memory=N     cache at most N bytes in memory
  --vips-cache-max-files=N      allow at most N open files
  --vips-cache-trace            trace operation cache
  --vips-cache-dump             dump operation cache on exit
  --vips-version                print libvips version

C:\Users\jcupi>dir/w c:\vips-dev-8.6\bin
 Volume in drive C is OS
 Volume Serial Number is 8E41-642A

 Directory of c:\vips-dev-8.6\bin

[.]                                 [..]                                libasprintf-0.dll
libatomic-1.dll                     libcairo-2.dll                      libcairo-gobject-2.dll
libcairo-script-interpreter-2.dll   libcharset-1.dll                    libcroco-0.6-3.dll
libexif-12.dll                      libexpat-1.dll                      libffi-6.dll
libfftw3-3.dll                      libfontconfig-1.dll                 libfreetype-6.dll
libgcc_s_seh-1.dll                  libgdk_pixbuf-2.0-0.dll             libgettextlib-0-19-8.dll
libgettextpo-1.dll                  libgettextsrc-0-19-8.dll            libgif-7.dll
libgio-2.0-0.dll                    libglib-2.0-0.dll                   libgmodule-2.0-0.dll
libgobject-2.0-0.dll                libgsf-1-114.dll                    libgsf-win32-1-114.dll
libgthread-2.0-0.dll                libharfbuzz-0.dll                   libharfbuzz-subset-0.dll
libiconv-2.dll                      libintl-9.dll                       libjpeg-62.dll
liblcms2-2.dll                      libMagickCore-6.Q16-2.dll           libMagickWand-6.Q16-2.dll
libmatio-4.dll                      libopenjp2.dll                      libopenslide-0.dll
libpango-1.0-0.dll                  libpangocairo-1.0-0.dll             libpangoft2-1.0-0.dll
libpangowin32-1.0-0.dll             libpixman-1-0.dll                   libpng16-16.dll
libpoppler-63.dll                   libpoppler-glib-8.dll               libquadmath-0.dll
librsvg-2-2.dll                     libsqlite3-0.dll                    libssp-0.dll
libstdc++-6.dll                     libtiff-5.dll                       libvips-42.dll
libvips-cpp-42.dll                  libvipsCC-42.dll                    libwebp-7.dll
libwebpdemux-2.dll                  libwebpmux-3.dll                    libxml2-2.dll
libz.dll                            vips.exe                            vipsedit.exe
vipsheader.exe                      vipsthumbnail.exe
              63 File(s)     72,777,102 bytes
               2 Dir(s)  638,847,635,456 bytes free

C:\Users\jcupi>pip list
Package    Version
---------- -------
cffi       1.11.5
pip        10.0.1
pycparser  2.18
pyvips     2.1.2
setuptools 39.0.1

C:\Users\jcupi>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> ^Z
jcupitt commented 6 years ago

Also, don't move DLLs around or copy files from previous versions. Just download 8.6.3-1 and unzip it.

HackersSpirit commented 6 years ago

image
image image image image I tried making the changes suggested by you and also there is no issue if i try to check the library using command prompt. It creates a problem only when i call it through my python code

jcupitt commented 6 years ago

Then your Python code does not have PATH set. You need to check the environment in which your Python interpreter is running. Is it running as a different user, for example? You might also need to log out and in again to have PATH set in all parts of your session.

HackersSpirit commented 6 years ago

Is vips library built on 32 bit or 64-bit system

jcupitt commented 6 years ago

The precompiled Windows binaries are 64-bit, but you can make your own 32-bit binaries, of course.

HackersSpirit commented 6 years ago

Thanks for the reply. Regarding the path i have checked all the paths but still i am unable to run. Can you please suggest of any other possibilities.

jcupitt commented 6 years ago

You could try this just before you import pyvips:

import os
print('path =', os.getenv('PATH'))

And verify that the correct value for PATH is set.

HackersSpirit commented 6 years ago

@jcupitt : Yes the path is set correctly. For both python interpreter and libvips

Sample output of above command:

('path =', 'C:\Users\thermo\Envs\PyCode\Scripts;C:\Python27\;C:\Python27\Scripts;;C:\vips-dev-8.6\bin;

Can i get the steps to build the library on my base machine instead of using the docker image.

kleisauke commented 6 years ago

It looks like libgobject-2.0-0.dll and libcairo-2.dll is included from another directory. You could try to reorder your PATH environment variable so that C:\vips-dev-8.6\bin is included first.

I'll do some tests on my Windows PC tonight.

HackersSpirit commented 6 years ago

@kleisauke: Sure will let u know

HackersSpirit commented 6 years ago

@jcupitt @kleisauke : Thanks a lot for you help. The issue got solved. As @jcupitt stated earlier it was path issue. @kleisauke : As per your suggestion i moved the vips-dev path to the top most of my path variables and it got resolved. Just one question how did you figure out libgobject-2.0-0.dll and libcairo-2.dll are causing issues :)

jcupitt commented 6 years ago

Oh good, I'm glad it's working.

You may find some other piece of software has now broken though :( The libvips DLLs at the front of the path may hide older versions of the same libraries that something else is using, and they might not be binary compatible. Hopefully it'll be OK.

HackersSpirit commented 6 years ago

@jcupitt : Yup, I am concerned about my flycapture sdk which is using the same dll's. Till now its working fine but cannot tell what part will create the issue. Just one clarification, can i reinitialize all the path in my virtual environment so that i can keep the earlier paths intact

jcupitt commented 6 years ago

I'd think so, but you'd need to test it (of course).

HackersSpirit commented 6 years ago

@jcupitt : Ok thanks

mherawi commented 6 years ago

Hi,

I'm getting the following error: "ModuleNotFoundError: No module named '_libvips'" image I already added the path into environmental variables and also tried a clean install with pip install --no-cache-dir pyvip. Can you please provide any suggestion on how to fix the issue? thanks

jcupitt commented 6 years ago

That looks like a different problem. Could you open a new issue, please?

jcupitt commented 5 years ago

Here's another solution for reference:

Don't change the system PATH since you can get DLL conflicts with other installed programs. Instead, set PATH in your Python program itself. Start your program with something like:

# change this for your install location and vips version, and remember to 
# use double backslashes
vipshome = 'c:\\vips-dev-8.7\\bin'

# set PATH
import os
os.environ['PATH'] = vipshome + ';' + os.environ['PATH']

# and now pyvips will pick up the DLLs in the vips area
import pyvips