RivuletStudio / rivuletpy

Robust 3D Neuron Tracing / General 3D tree structure extraction in Python for 3D images powered by the Rivulet2 algorithm. Pain-free Install & use in 5 mins.
BSD 3-Clause "New" or "Revised" License
66 stars 16 forks source link

Failed to find TIFF library #8

Closed elktoe closed 6 years ago

elktoe commented 6 years ago

Hi, had this issue come up the first time I tried rtrace

File "//anaconda/lib/python3.5/site-packages/libtiff/libtiff_ctypes.py", line 46, in raise ImportError('Failed to find TIFF library. Make sure that libtiff ' ImportError: Failed to find TIFF library. Make sure that libtiff is installed and its location is listed in PATH|LD_LIBRARY_PATH|..

Thanks!

lsqshr commented 6 years ago

Hi thanks for trying rivuletpy out.

It seems your pylibtiff package was not installed.

Would you pls try pip install libtiff>=0.4.1 within your conda environment?

lsqshr commented 6 years ago

A few questions to narrow it down: Which OS are you using? Did you install rivuletpy from the python source or using pip install rivuletpy?

In case you are doing this on windows, there was a known issue for compiling pylibtiff on windows. You can try to install a pre-compiled pylibtiff from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pylibtiff Download the libtiff‑0.4.2‑cp35‑cp35m‑win_amd64.whl. And then run pip install libtiff‑0.4.2‑cp35‑cp35m‑win_amd64.whl

Pls let me know if it works for you. If it does, I will add this solution to README.

elktoe commented 6 years ago

Hi! Yes, I'm excited to try out rivuletpy. Im on a Mac, OSX 10.10.5 I checked before, and libtiff was installed..just not in the correct place?

I wasn't in a virtual environment before, so I set one up (0A. Setup the Anaconda environment). I followed 1. Setup the dependencies, and 2A. Install Rivuletpy from the Pypi (I'm using Anaconda).

I've gotten a different error now, see below: $ rtrace -f 161117-870-A0.tif -t 10 RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa Traceback (most recent call last): File "//anaconda/envs/riv/bin/rtrace", line 7, in <module> from rivuletpy.trace import R2Tracer File "//anaconda/envs/riv/lib/python3.5/site-packages/rivuletpy/trace.py", line 4, in <module> import skfmm File "//anaconda/envs/riv/lib/python3.5/site-packages/skfmm/__init__.py", line 51, in <module> from .pfmm import distance, travel_time, extension_velocities File "//anaconda/envs/riv/lib/python3.5/site-packages/skfmm/pfmm.py", line 4, in <module> from .cfmm import cFastMarcher ImportError: numpy.core.multiarray failed to import

lsqshr commented 6 years ago

It seems that the numpy you got is not up-to-date. Can you pls try pip install -U numpy

elktoe commented 6 years ago

Back to the original error. I tried your first suggestion again (pip install libtiff>=0.4.1) but am still getting the same libtiff error (see below). Thanks for you help! It is appreciated!

Traceback (most recent call last): File "//anaconda/envs/riv/bin/rtrace", line 102, in img = loadimg(args.file) File "//anaconda/envs/riv/lib/python3.5/site-packages/rivuletpy/utils/io.py", line 13, in loadimg img = loadtiff3d(file) File "//anaconda/envs/riv/lib/python3.5/site-packages/rivuletpy/utils/io.py", line 26, in loadtiff3d from libtiff import TIFF File "//anaconda/envs/riv/lib/python3.5/site-packages/libtiff/init.py", line 20, in from .libtiff_ctypes import libtiff, TIFF, TIFF3D File "//anaconda/envs/riv/lib/python3.5/site-packages/libtiff/libtiff_ctypes.py", line 46, in raise ImportError('Failed to find TIFF library. Make sure that libtiff ' ImportError: Failed to find TIFF library. Make sure that libtiff is installed and its location is listed in PATH|LD_LIBRARY_PATH|..

elktoe commented 6 years ago

I also tried adding it to .bash_profile with

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH://anaconda/envs/riv/lib/python3.5/site-packages/libtiff"

I am working on a Mac, is this version of Rivulet compatible with Mac OS?

Thank-you!

lsqshr commented 6 years ago

I do not have a mac at hand now. However, we tested on mac before and ensured everything works well on macs.

On my linux machine, I find the compiled libtiff.so under anaconda/envs/riv/lib instead of anaconda/envs/riv/lib/python3.5/site-packages/libtiff

Can you pls try export LD_LIBRARY_PATH="$LD_LIBRARY_PATH://anaconda/envs/riv/lib/" instead? & Let's see how it goes

elktoe commented 6 years ago

Tried it, same error comes up :(

lsqshr commented 6 years ago

Interesting. Not sure why the compiled libtiff is not found.

How about trying to install the mac compiled libtiff with brew brew install libtiff

jackjacktang commented 6 years ago

I have actually experienced the same problem as elktoe when I tried to install libtiff on my current Mac workstation, this can be solved perfectly with mac compiled libtiff with brew. Make sure you get rid of the previous not working libtiff module before you install mac compiled libtiff pip3 uninstall libtiff then brew install libtiff as suggested by @lsqshr, see if it works.

lsqshr commented 6 years ago

@jackjacktang Thanks for the note Jack. This is helpful! If this is working, I will add it to README.

elktoe commented 6 years ago

Yup, brew install libtiff worked for me.

A couple quick questions. How long does it usually take to make a trace (for example image size 512x512x40)

Also, unless you specify the name of the output file (-o) or to view the reconstructed trace (-v), nothing will be saved? I ran a test trace and at the end no output files were created (unless they are in a folder I can't find). Just checking that this usually how rivuletpy runs and that I need to specify an output file. And the output is a .swc file?

thanks for your help!

lsqshr commented 6 years ago

Great to know such a workaround. I will add it in our README

The running time of rivulet2 algorithm depends on both the image size (fast marching) as well as the number of foreground voxels (back-tracking). A volume with 512x512x40 is sort of large but I guess it would finish within 5 mins. For most of the images, we would add a -z 0.7 to speed up the tracing by downsampling the image. Then such an image would finish within around 2 mins.

Suppose you are trying to trace /SOMEPATH/image.tif and do not specify -o, it should output a swc at /SOMEPATH/image.tif.r2.swc

PuTeGuo commented 1 year ago

Hi! How could I solve this problem if I was in anaconda virtual envs?(without using brew)

lsqshr commented 1 year ago

@Red-scarf-0317 thanks for reaching out. can you share a bit more details: (1) what is the exact error msg you are seeing? (2) which OS system you are using (MAC/Windows/Linux)?

maissansb commented 8 months ago

Hi, im on a virtual environment and when I run pip install libtiff I get this error, ( No module named 'numpy' ) even though I installed numpy and used it and double checked its installed. Im on MacOS 14.3.1 and PYTHON 3.12.2