Unable to run ./install_sct (v4.2.1)

Hello!

We tried to upload our version to sct_4.2.1 and we found the following issue:

extop@:/aran/spinalcordtoolbox-4.2.1$ ./install_sct
*******************************
* Welcome to SCT installation *
*******************************
Checking OS type and version...

Linux vh 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Checking requirements...

ERROR: Shell was not recognized: /bin/sh

Installation failed

My knowledge of programation says that this will be not an sct problem but something i did wrong on my end..

Before that, we tried to run some orders with sct and we found the first of our problems, something with the Keras installation. I am uploading the output from **sct_check_dependencies**.

extop@:/aran/spinalcordtoolbox-4.2.1$ sct_check_dependencies 

--
Spinal Cord Toolbox (git-master-2c66d15d04d1048cc1ebbe65dd266ebf4bd7528f)

SCT info:
- version: git-master-2c66d15d04d1048cc1ebbe65dd266ebf4bd7528f
- path: /home/extop/sct_git
OS: linux (Linux-4.18.0-25-generic-x86_64-with-debian-buster-sid)
CPU cores: Available: 12, Used by SCT: 12
RAM: MemTotal:       131698196 kB
Memory      128611        9226       16066         365      103318      117805
Swap:           975           6         969
Check Python executable.............................[OK]
  Using bundled python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) 
[GCC 7.3.0] at /home/extop/sct_git/python/envs/venv_sct/bin/python
Check if data are installed.........................[OK]
Check if numpy is installed.........................[OK] (1.17.2)
Check if cryptography is installed..................[OK] (2.7)
Check if dipy is installed..........................[OK] (1.0.0)
Check if futures is installed.......................[OK]
Check if h5py is installed..........................[OK] (2.10.0)
Check if Keras is installed.........................Traceback (most recent call last):
  File "/home/extop/sct_git/scripts/sct_check_dependencies.py", line 385, in <module>
    main()
  File "/home/extop/sct_git/scripts/sct_check_dependencies.py", line 279, in main
    module = module_import(module_name, suppress_stderr)
  File "/home/extop/sct_git/scripts/sct_check_dependencies.py", line 108, in module_import
    module = importlib.import_module(module_name)
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/site-packages/keras/utils/__init__.py", line 26, in <module>
    from .vis_utils import model_to_dot
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/site-packages/keras/utils/vis_utils.py", line 7, in <module>
    from ..models import Model
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/site-packages/keras/models.py", line 10, in <module>
    from .engine.input_layer import Input
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/site-packages/keras/engine/__init__.py", line 8, in <module>
    from .training import Model
  File "/home/extop/sct_git/python/envs/venv_sct/lib/python3.6/site-packages/keras/engine/training.py", line 973
    max_queue_size=10,
                 ^
SyntaxError: invalid syntax

Any ideas on how to proceed? Hopefully, somebody can help me with the installation problem and maybe the SCT team wants to take a look at the keras thing?

thanks

Hi @Aran

Sorry for the late response. The install script is running under bash, but launched tcsh commands such as setenv (which should be run outside of the script).

Could you please copy this script install_sct_test (20.9 KB) under SCT’s folder and run this modified installer:

./install_sct_test

Let me know if that solves your issue

Hello Julien,
unfortunatey here is the output

extop@://aran/spinalcordtoolbox-4.2.1$ ./install_sct_test 
./install_sct_test: 45: ./install_sct_test: Syntax error: "(" unexpected
extop@vh://aran/spinalcordtoolbox-4.2.1$ ./install_sct_test 

I am unable to find the appropriate place to put the “(” that is missing.

Apologies and thank you

Can you please try with this new script: install_sct_test_v2 (20.9 KB)

After you downloaded it, copy it to SCT’s folder and run:

chmod 775 install_sct_test_v2
./install_sct_test_v2

Then please, copy/paste the entire Terminal output in this thread in case the installation fails again.

Hello @jcohenadad,

Unfortunately, the installation failed again

extop@:/aran/spinalcordtoolbox-4.2.1$ chmod 775 install_sct_test_v2 
extop@:/aran/spinalcordtoolbox-4.2.1$ ./install_sct_test_v2 

*******************************
* Welcome to SCT installation *
*******************************

Checking OS type and version...

Linux 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Checking requirements...


ERROR: Shell was not recognized: /bin/sh

Installation failed

extop@:/aran/spinalcordtoolbox-4.2.1$

Sorry about all these issues. I need more verbose, could you please try with this new script: install_sct_test_v3 (20.9 KB)

After you downloaded it, copy it to SCT’s folder and run:

chmod 775 install_sct_test_v3
./install_sct_test_v3

Then please, copy/paste the entire Terminal output in this thread.

dear julien,

Do not worry about having so many issues, happy to help!

extop@/aran/spinalcordtoolbox-4.2.1$ chmod 775 install_sct_test_v3
extop@/aran/spinalcordtoolbox-4.2.1$ ./install_sct_test_v3
# a folder that already exists, therefore, it should only be used for debugging mode.

# Where tmp file are stored
TMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'TMP_DIR')
# Start Directory So we go back there at the end of the Script
SCT_SOURCE=$PWD
SCRIPT_DIR="scripts"
DATA_DIR="data"
PYTHON_DIR="python"
BIN_DIR="bin"
# Misc
OSXVERSUPPORTED=12  # minimum version of OSX supported


# ======================================================================================================================
# FUNCTIONS
# ======================================================================================================================

# Print with color
# @input1: {info, code, error}: type of text
# @input2: text to print
function print() {
  type=$1
  txt=$2
  case $type in
  # Display useful info (green)
  info)
    echo -e "\n\033[0;32m${txt}\033[0m\n"
    ;;
  # To interact with user (no carriage return) (light green)
  question)
    echo -e -n "\n\033[0;92m${txt}\033[0m"
    ;;
  # To display code that is being run in the Terminal (blue)
  code)
    echo -e "\n\033[0;34m${txt}\033[0m\n"
    ;;
  # Warning message (yellow)
  warning)
    echo -e "\n\033[0;93m${txt}\033[0m\n"
    ;;
  # Error message (red)
  error)
    echo -e "\n\033[0;31m${txt}\033[0m\n"
    ;;
  esac
}

# Elegant exit with colored message
function die() {
  print error "$1"
  exit 1
}

# Run a command and display it in color. Exit if error.
# @input: string: command to run
function run() {
  cmd=$1
  print code "$cmd"
  $cmd
  if [[ $? != 0 ]]; then
    die "ERROR: Command failed."
  fi
}

# Force a clean exit
function finish() {
  # Catch the last return code
  value=$?
  # Get back to starting point
  cd $SCT_SOURCE
  if [[ $value -eq 0 ]]; then
    print info "Installation finished successfully!"
  elif [[ $value -eq 99 ]]; then
    # Showing usage with -h
    echo ""
  else
    print error "Installation failed"
  fi
  # clean tmp_dir
  rm -r $TMP_DIR
  exit $value
}

# reenable tty echo when user presses keyboard interrupt and output non-zero status for finish() function
detectKeyboardInterrupt() {
      # reenable tty echo
      print error "Installation aborted by the user."
      stty icanon echo echok
      exit 1
}

# Fetches the OS type
# @output: OS var is modified with the appropriate OS
function fetch_os_type() {
  print info "Checking OS type and version..."
  OSver="unknown"  # default value
  uname_output=`uname -a`
  echo $uname_output
  # OSX
  if echo $uname_output | grep -i darwin >/dev/null 2>&1; then
    # Fetch OSX version
    sw_vers_output=`sw_vers | grep -e ProductVersion`
    echo "$sw_vers_output"
    OSver=`echo $sw_vers_output | cut -c 20- | cut -c -2`
    # Make sure OSver us supported
    if (("$OSver" < "$OSXVERSUPPORTED")); then
      die "Sorry, this version of OSX (10.$OSver) is no more supported. The minimum version is 10.$OSXVERSUPPORTED".
    fi
    # Fix for non-English Unicode systems on MAC
    if [[ -z $LC_ALL ]]; then
      export LC_ALL=en_US.UTF-8
    fi

    if [[ -z $LANG ]]; then
      export LANG=en_US.UTF-8
    fi
    OS=osx
    # make sure bashrc is loaded when starting a new Terminal
    force_bashrc_loading
  # Linux
  elif echo $uname_output | grep -i linux >/dev/null 2>&1; then
    # CentOS 6.X
    if cat /etc/issue | grep -i centos | grep 6. 2>&1; then
      OS=linux_centos6
    # RedHat 6.X
    elif cat /etc/issue | grep -i Red | grep 6. 2>&1; then
      OS=linux_centos6
    # Other Linux
    else
      OS=linux
    fi
  else
    die "Sorry, the installer only supports Linux and OSX, quitting installer"
  fi
}

# Checks if the necessary tools for SCT are installed on the machine
function check_requirements() {
  print info "Checking requirements..."
  # check curl
  if [[ ! $(which curl) && ! $(which wget) ]]; then
    die "ERROR: neither \"curl\" nor \"wget\" is installed. Please install either of them and restart SCT installation."
  fi
  # check gcc
  gcc --version > /dev/null 2>&1  # run silently, then check output status
  if [[ $? -ne 0 ]]; then
    print warning "WARNING: \"gcc\" is not installed."
    if [[ $OS == "osx" ]]; then
      while [[ ! $GCC_INSTALL =~ ^([Yy](es)?|[Nn]o?)$ ]]; do
        print question "Do you want to install it now? (accepting to install \"gcc\" will also install \"brew\" in case it is not installed already)? [y]es/[n]o: "
        read GCC_INSTALL
      done
      if [[ $GCC_INSTALL =~ [Yy](es)? ]]; then
        if [[ ! $(which brew) ]]; then
          yes | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
        fi
        yes | brew install gcc
        # check if gcc install ran properly
        gcc --version > /dev/null 2>&1  # run silently, then check output status
        if [[ $? -ne 0 ]]; then
          die "ERROR: Installation of \"gcc\" failed. Please contact SCT team for assistance."
        fi
      else
        die "Please install \"gcc\" and restart SCT installation."
      fi
    else
      die "Please install \"gcc\" and restart SCT installation. On Debian/Ubuntu, run: \"apt install gcc\". On CentOS/RedHat, run: \"yum -y install gcc\"."
    fi
  fi
  print info "OK!"
}

# Gets the shell rc file path based on the default shell.
# @output: THE_RC and RC_FILE_PATH vars are modified
function get_shell_rc_path() {
  if [[ $SHELL == *"bash"* ]]; then
    THE_RC="bash"
    RC_FILE_PATH="$HOME/.bashrc"
  elif [[ $SHELL == *"zsh"* ]]; then
    THE_RC="bash"
    RC_FILE_PATH="$HOME/.zshrc"
  elif [[ $SHELL == *"csh"* ]]; then
    THE_RC="csh"
    RC_FILE_PATH="$HOME/.cshrc"
  else
    die "ERROR: Shell was not recognized: $SHELL"
  fi
}

# Force bashrc loading
function force_bashrc_loading() {
  sourceblock="
if [[ -n \"\$BASH_VERSION\" ]]; then
    # include .bashrc if it exists
    if [[ -f \"\$HOME/.bashrc\" ]]; then
    . \"\$HOME/.bashrc\"
    fi
fi"
  for profiles in ~/.bash_profile ~/.bash_login ~/.profile; do
    if [[ -a $profiles ]]; then
      if ! grep -E "(\.|source) .*bashrc" $profiles >/dev/null 2>&1; then
        echo "$sourceblock" >>$profiles
      fi
      bidon=0
      break
    fi
  done

  if [[ -z $bidon ]]; then
    echo "$sourceblock" >>~/.bash_profile
  fi
}

# Installation text to insert in shell config file
function edit_shellrc() {
  # Write text common to all shells
  echo
  echo "" >>$RC_FILE_PATH
  echo "# SPINALCORDTOOLBOX (installed on $(date +%Y-%m-%d\ %H:%M:%S))" >>$RC_FILE_PATH
  echo $DISPLAY_UPDATE_PATH >>$RC_FILE_PATH
  # Switch between shell
  if [[ $THE_RC == "bash" ]]; then
    echo "export SCT_DIR=$SCT_DIR" >>$RC_FILE_PATH
    echo "export MPLBACKEND=Agg" >>$RC_FILE_PATH
  elif [[ $THE_RC == "csh" ]]; then
    echo "setenv SCT_DIR $SCT_DIR" >>$RC_FILE_PATH
    echo "setenv MPLBACKEND Agg" >>$RC_FILE_PATH
  fi
  # add line
  echo "" >>$RC_FILE_PATH
}

# Download from URL using curl/wget
function download() {
  # Use curl or wget to download goodies
  e_status=0
  # Try with wget
  if [[ $(which wget) ]]; then
    cmd="wget -O $1 $2"
    print code "$cmd"
    $cmd
    e_status=$?
    echo exit status is $e_status
  fi
  # Try with curl
  if [[ $(which curl) && ! -e $1 ]]; then
    cmd="curl -o $1 -L $2"
    print code "$cmd"
    $cmd
    e_status=$?
    echo exit status is $e_status
  fi
  # check success
  if [[ $e_status -ne 0 || ! -e $1 ]]; then
    die "The download of $2 failed\n
Please check your internet connection before relaunching the installer\n"
  fi
}

# Usage of this script
function usage() {
  echo -e "\nUsage: $0 [-d] [-b] [-v]" 1>&2
  echo -e "\nOPTION"
  echo -e "\t-d \v Prevent the (re)-installation of the \"data/\" directory "
  echo -e "\n\t-b \v Prevent the (re)-installation of the SCT binaries files "
  echo -e "\n\t-v \v Full verbose"
}


# ======================================================================================================================
# SCRIPT STARTS HERE
# ======================================================================================================================

# This trap specifically catches keyboardInterrupt and output a non-zero status before running finish()
trap detectKeyboardInterrupt INT
# Set a trap which, on shell error or shell exit, runs finish()
trap finish EXIT

print info "
*******************************
* Welcome to SCT installation *
*******************************
"


*******************************
* Welcome to SCT installation *
*******************************



# ----------------------------------------------------------------------------------------------------------------------
# CLI parser
# ----------------------------------------------------------------------------------------------------------------------

fetch_os_type

Checking OS type and version...

Linux vh 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
check_requirements

Checking requirements...


OK!


# Transform  long option "--long" into short option  "-l"
for arg in "$@"; do
  shift
  case "$arg" in
    *)       set -- "$@" "$arg"
  esac
done

while getopts ":dhbpv" opt; do
  case $opt in
  d)
    echo " data directory will not be (re)-installed"
    NO_DATA_INSTALL=yes
    ;;
  b)
    echo " SCT binaries will not be (re)-installed "
    NO_SCT_BIN_INSTALL=yes
    ;;
  v)
    echo " Full verbose!"
    set -x
    ;;
  h)
    usage
    exit 99
    ;;
  \?)
    usage
    exit 99
    ;;
  esac
done


# ----------------------------------------------------------------------------------------------------------------------
# Prepare installation
# ----------------------------------------------------------------------------------------------------------------------

# Catch SCT version
if [[ -e "version.txt" ]]; then
  SCT_VERSION=$(cat version.txt)
else
  die "ERROR: version.txt not found. \n
The install_sct script must be executed from the source directory"
fi

# Get installation type (from git or from package)
if [[ "x$SCT_INSTALL_TYPE" == "x" ]]; then
  if [[ -d ".git" ]]; then
    # folder .git exist, therefore it is a git installation
    SCT_INSTALL_TYPE="in-place"
  else
    SCT_INSTALL_TYPE="package"
  fi
fi

# Define sh files
get_shell_rc_path

ERROR: Shell was not recognized: /bin/sh

finish

Installation failed

OK, I see what the problem is.
What is the output of:

find ~/.* -maxdepth 0 -type f

Also, do you know what RC file you are using? (the one that is launched to set up environment variables)?

The output you asked is

extop@:~$ find ~/.* -maxdepth 0 -type f
/home/extop/.bash_history
/home/extop/.bashrc
/home/extop/.bashrc_20200115
/home/extop/.calc_history
/home/extop/.ICEauthority
/home/extop/.recently-used
/home/extop/.Rhistory
/home/extop/.selected_editor
/home/extop/.viminfo
/home/extop/.xdebug_tkmedit

And if i understood your question right, i think we use bashrc, does it make sense?

thanks

OK great, this one should work: install_sct_test_v4 (21.0 KB)

Amazing!

It finally worked, thank you really much!

1 Like