Header

Calling TORTOISE modules from Python

Submitted by tecork on

Hello, 

I have had TORTOISE for a while now and was interested in incorporating the modules into my workflow. I am on MacOS Catalina (Version 10.15.7). and using python 3. I can run the following command from the terminal just fine:

ImportNIFTI -i /Users/Tyler/Vol_1_LR.nii -b /Users/Tyler/Vol_1_LR.bval -v /Users/Tyler/Vol_1_LR.bvec -p vertical

However, when I run it using subprocess in Python 3, like the following:

>>> import subprocess

>>> cmd = 'ImportNIFTI -i /Users/Tyler/Vol_1_LR.nii -b /Users/Tyler/Vol_1_LR.bval -v /Users/Tyler/Vol_1_LR.bvec -p vertical'

>>> list_files = subprocess.run(cmd, shell=True)

I received the following error:

dyld: Library not loaded: /usr/local/opt/llvm/lib/libomp.dylib

Referenced from: /Users/Tyler/TORTOISE_V3.2.0/DIFFPREPV320/bin/bin/ImportNIFTI

Reason: image not found

I suspect the issue is similar, if not the same as the post regarding MATLAB. My intuition was to try getting it to run through MATLAB and that should also fix the python problem if the .bash_profile was updated. 

Using the current setting and a clean install of TORTOISE, these are the paths I currently have in my .bash_profile:

export PATH=/Users/Tyler/TORTOISE_V3.2.0/DIFFPREPV320/bin/bin:$PATH

export PATH=/Users/Tyler/TORTOISE_V3.2.0/DIFFCALC/DIFFCALCV320:$PATH

export PATH=/Users/Tyler/TORTOISE_V3.2.0/DRBUDDIV320/bin:$PATH

export PATH=/Users/Tyler/TORTOISE_V3.2.0/DRTAMASV320/bin:$PATH

export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Users/Tyler/TORTOISE_V3.2.0/DRBUDDIV320/bin

Thank you for your help!

Best,

Tyler Cork

Submitted by irfanogl on Mon, 10/18/2021 - 09:29

Permalink

Hello,

Unfortunately, this is a problem with MACs.

TORTOISE installation scripts add the necessary library paths to your files such as .bash_profile.

When executables are called from command line, these paths are included.

However, when a script calls these executables these paths are not transferred to the calling script so as you did they have to be manually included in every calling script.

Unfortunately, not much we can do about this.