Successfully installed libtiff but while importing getting error

旧巷老猫 提交于 2021-02-07 04:30:28

问题


I installed libtiff successfully in python 2.7 using "pip install libtiff". It successfully installed the libtiff-0.4.0 package. But when I am importing the package using "import libtiff".I get an error which is:

     Traceback (most recent call last):
    File "D:/Python/p1.py", line 1, in <module>
     import libtiff
    File "D:\Python\lib\site-packages\libtiff\__init__.py", line 20, in <module>
      from .libtiff_ctypes import libtiff, TIFF, TIFF3D
        File "D:\Python\lib\site-packages\libtiff\libtiff_ctypes.py", line 41,         in <module>
    raise ImportError('Failed to find TIFF library. Make sure that libtiff is    installed and its location is listed in PATH|LD_LIBRARY_PATH|..')
ImportError: Failed to find TIFF library. Make sure that libtiff is installed and its location is listed in PATH|LD_LIBRARY_PATH|..

Kindly Clarify.


回答1:


I got libtiff to work with the following steps:

  • install Microsoft Visual C++ 9.0
  • install GnuWin32 TIFF
  • pip install libtiff

Then, in my script I just used the os library to add the necessary folder to my path:

import os
os.environ["PATH"] += os.pathsep + "C:\\Program Files\\GnuWin32\\bin"

(Of course you can edit your path variable manually as well.)




回答2:


I encounter the same problem, but when I install the packge offline I worked well.

you should download libtiff at https://www.lfd.uci.edu/~gohlke/pythonlibs/ where you search

libtiff in the web, then you can obtain it.

last, you can pip install that in its path.



来源:https://stackoverflow.com/questions/39483328/successfully-installed-libtiff-but-while-importing-getting-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!