Skip to content

How to Debug “greedy not found” After a pip Install

You installed Greedy. pip show looks fine. Then:

./register_OslogMRI.sh: line 1: #!/bin/bash: No such file or directory
ERROR: greedy not found (greedy). Put it on PATH or set GREEDY=/full/path/to/greedy

Those are two failures. Treat them as one and you will keep grepping site-packages for a binary that is not there.

What the script expects

Classic Greedy is one executable:

greedy -d 3 -a -i fixed.nii.gz moving.nii.gz -o affine.mat

Lab scripts assume greedy is on PATH, or GREEDY is the file, not a folder.

What pip actually gave you

pip install picsl-greedy installs picsl_greedy: a .so, a .libs dir, and dist-info. No greedy command.

which python && which pip
pip show picsl-greedy
python -c "from picsl_greedy import Greedy3D; print('ok')"

Requires: numpy, SimpleITK, typing_extensions means the Python wrapper. which greedy failing is expected.

Trap 1: the path wrapped in the terminal

pip show printed a long Location:. A wrapped ls split site-packages across lines and looked like a missing install.

Ask Python instead:

find "$(python -c 'import picsl_greedy, os; print(os.path.dirname(picsl_greedy.__file__))')" -iname '*greedy*'

If you only see the .so, .libs, and dist-info, stop hunting. networkx/.../greedy_coloring.py is unrelated.

Trap 2: GREEDY is not a search root

Scripts usually do GREEDY=${GREEDY:-greedy} then command -v. That variable must be an executable:

export GREEDY="$HOME/bin/greedy"           # ok
export GREEDY=.../site-packages/greedy-git # directory / sourcenot ok

GREEDY_DATA_ROOT in the C++ tool is only a prefix for data files.

See also  Pip package installation specifications and Error fixed: pip install -U 'accelerate>=0.26.0' ERROR: Invalid requirement: "'accelerate": Expected package name at the start of dependency specifier 'accelerate

Trap 3: #!/bin/bash: No such file

/bin/bash exists. The shebang was saved as #!/bin/bash\r. The kernel looks up /bin/bash\r.

head -1 register_OslogMRI.sh | od -c | head
sed -i 's/\r$//' register_OslogMRI.sh

Fix CRLF before you debug Greedy.

The missing piece: a CLI shim

mkdir -p "$HOME/bin"
cat > "$HOME/bin/greedy" << 'EOF'
#!/usr/bin/env python
import sys
from picsl_greedy import Greedy3D
g = Greedy3D()
g.execute(" ".join(sys.argv[1:]))
EOF
chmod +x "$HOME/bin/greedy"
export PATH="$HOME/bin:$PATH"
export GREEDY="$HOME/bin/greedy"
hash -r
greedy -h | head

Point the shebang at the same conda Python that can import picsl_greedy if env python is the wrong interpreter.

join(argv) is enough for normal Greedy flags. Paths with spaces may need the script rewritten to call Greedy3D directly.

Order that works

  1. Same python/pip as the install
  2. Greedy3D imports
  3. Unix line endings on the script
  4. GREEDY or PATH points at a real executable (binary or shim)
  5. Only then build from source

The engine was installed. The interface the shell script expected was not.

Full write-up:


Discover more from Science Safari

Subscribe to get the latest posts sent to your email.

Leave a Reply

error: Content is protected !!