libvips / pyvips

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

cannot load library 'C:\vips-dev-8.12\bin\libgobject-2.0-0.dll': error 0x7e #286

Open MAJAQA opened 2 years ago

MAJAQA commented 2 years ago

Just install latest pyvips (first install on my local machine as I was previously working on a VM) I don't get it: seen this issue before on the forum (https://github.com/kleisauke/net-vips/issues/3) , followed all suggestions; but keep getting:

_path = C:\vips-dev-8.12\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Users\maja\AppData\Local\Microsoft\WindowsApps;
Traceback (most recent call last):
  File "C:\Users\maja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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 "C:\Data\techtime\test_local.py", line 20, in <module>
    import pyvips as py
  File "C:\Users\maja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyvips\__init__.py", line 70, in <module>
    gobject_lib = ffi.dlopen(_gobject_libname)
  File "C:\Users\maja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\maja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\maja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 828, in _load_backend_lib
    return backend.load_library(path, flags)
OSError: cannot load library 'C:\vips-dev-8.12\bin\libgobject-2.0-0.dll': error 0x7e_

My python code uses:

import os
print('path =', os.getenv('PATH'))
vipshome = 'C:\\vips-dev-8.12\\bin'
os.environ['PATH'] = vipshome + ';' + os.environ['PATH']
print('path =', os.getenv('PATH'))
import pyvips as py_

And environment:

image

jcupitt commented 2 years ago

Hi @MAJAQA,

Did you install python via the MS store? I think that version won't work with third-party libraries (like pyvips), you are locked into their set of extensions.

I just tried installing the python from the python.org website and it worked:

Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> vipshome = 'C:\\Users\\jcupi\\vips-dev-8.12\\bin'
>>> import os
>>> os.environ['PATH'] = vipshome + ';' + os.environ['PATH']
>>> import pyvips
>>>
MAJAQA commented 2 years ago

Indeed this was the root cause. Thanks.

jcupitt commented 2 years ago

To copy-paste from the linked issue, the MS store version seems to run at least partially inside the UWP sandbox, so it will not work with things like pyvips.

CristiFati commented 1 year ago

I think it's actually #351.