我需要为项目使用libtiff


作业系统:Windows 10
Python版本:3.6.6;
使用以下命令安装Libtiff:pip install libtiff
https://sourceforge.net/projects/gnuwin32/安装的Tiff
添加的环境路径:C:\Program Files\GnuWin32\bin


完成这些步骤后,当我运行导入libtiff时,出现以下错误:

OSError                                   Traceback (most recent call last)
<ipython-input-1-3fa0885ae753> in <module>
     20 import os
     21 import pickle
---> 22 from libtiff import TIFF
     23 import libtiff
     24 libtiff.libtiff_ctypes.suppress_warnings()

c:\users\ajain7\appdata\local\programs\python\python36\lib\site-packages\libtiff\__init__.py in <module>
     18 __all__ = ['TIFF', 'TIFF3D', 'TIFFfile', 'TiffArray', 'TiffFile', 'TiffFiles', 'TiffChannelsAndFiles', 'TiffBase']
     19
---> 20 from .libtiff_ctypes import libtiff, TIFF, TIFF3D
     21 from .tiff import TIFFfile, TIFFimage, TiffArray
     22 from .tiff_file import TiffFile

c:\users\ajain7\appdata\local\programs\python\python36\lib\site-packages\libtiff\libtiff_ctypes.py in <module>
     48                       'PATH|LD_LIBRARY_PATH|..')
     49
---> 50 libtiff = ctypes.cdll.LoadLibrary(lib)
     51
     52 libtiff.TIFFGetVersion.restype = ctypes.c_char_p

c:\users\ajain7\appdata\local\programs\python\python36\lib\ctypes\__init__.py in LoadLibrary(self, name)
    424
    425     def LoadLibrary(self, name):
--> 426         return self._dlltype(name)
    427
    428 cdll = LibraryLoader(CDLL)

c:\users\ajain7\appdata\local\programs\python\python36\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    346
    347         if handle is None:
--> 348             self._handle = _dlopen(self._name, mode)
    349         else:
    350             self._handle = handle

OSError: [WinError 193] %1 is not a valid Win32 application

最佳答案

可能发生了另一件事。 VS代码从预定义的OS位置自动搜索numpy和其他软件包。您可能使用的是numpy的32位版本,而不是64位版本。要解决此问题,请通过键入libtiff从所有位置卸载pip uninstall libtiff

关于python - OSError:[WinError 193]%1不是有效的Win32应用程序(LibTiff),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54049993/

10-09 02:45