问题
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