我正在尝试像这样在 ubuntu14.04 中安装 Anaconda3:
seyyedhossein@hossein:~$ sh Anaconda3-4.2.0-Linux-x86_64.sh
我得到:
Anaconda3-4.2.0-Linux-x86_64.sh: 16: Anaconda3-4.2.0-Linux-x86_64.sh: 0: not found
Anaconda3-4.2.0-Linux-x86_64.sh: 61: Anaconda3-4.2.0-Linux-x86_64.sh: 0: not found
Anaconda3-4.2.0-Linux-x86_64.sh: 75: Anaconda3-4.2.0-Linux-x86_64.sh: Syntax error: word unexpected (expecting ")")
这里有什么问题?
我已成功将其安装在另一个帐户(最初是从该帐户下载的)上。但是当我登录到我的新帐户时,它就无法运行!
更新:
cat 命令的输出:
#!/bin/bash
# Copyright (c) 2012-2016 Continuum Analytics, Inc.
# All rights reserved.
#
# Name: Anaconda3
# Version: 4.2.0
# Packages: 195
# PLAT: linux-64
# DESCR: 4.1.1-889-g7ce9b7f
# BYTES: 478051940
# LINES: 558
# MD5: 1ee1f5cb1d92a230e59cc5fce0dca5ba
unset LD_LIBRARY_PATH
echo "$0" | grep '\.sh$' >/dev/null
if (( $? )); then
echo 'Please run using "bash" or "sh", but not "." or "source"' >&2
return 1
fi
THIS_DIR=$(cd $(dirname $0); pwd)
THIS_FILE=$(basename $0)
THIS_PATH="$THIS_DIR/$THIS_FILE"
PREFIX=$HOME/anaconda3
BATCH=0
FORCE=0
while getopts "bfhp:" x; do
case "$x" in
h)
echo "usage: $0 [options]
Installs Anaconda3 4.2.0
-b run install in batch mode (without manual intervention),
it is expected the license terms are agreed upon
-f no error if install prefix already exists (force)
-h print this help message and exit
-p PREFIX install prefix, defaults to $PREFIX
"
exit 2
;;
b)
BATCH=1
;;
f)
FORCE=1
;;
p)
PREFIX="$OPTARG"
;;
?)
echo "Error: did not recognize option, please try -h"
exit 1
;;
esac
done
# verify the size of the installer
wc -c "$THIS_PATH" | grep 478051940 >/dev/null
if (( $? )); then
echo "ERROR: size of $THIS_FILE should be 478051940 bytes" >&2
exit 1
fi
if [[ $BATCH == 0 ]] # interactive mode
then
if [[ `uname -m` != 'x86_64' ]]; then
echo -n "WARNING:
Your operating system appears not to be 64-bit, but you are trying to
install a 64-bit version of Anaconda3.
Are sure you want to continue the installation? [yes|no]
[no] >>> "
read ans
if [[ ($ans != "yes") && ($ans != "Yes") && ($ans != "YES") &&
($ans != "y") && ($ans != "Y") ]]
问题出在脚本上:尽管它在自己的文档中声称它可以由 运行
sh
,即任何标准 POSIX shell,但它实际上需要bash
.该构造
(( $? ))
不是有效的 POSIX sh,也不是($ans != "yes")
何时$ans
为空。它们在bash
任何一个中都几乎无效(TBH,这是我 20 年来第一次看到这个成语(( $? ))
),但显然bash
让它过去了。解决方案:使用 bash 运行:
bash Anaconda3-4.2.0-Linux-x86_64.sh
您给出的 sh 命令假定 .sh 文件位于您的主目录中。它可能位于其他地方,在这种情况下,您必须为其指定文件所在位置的路径名。
示例:如果文件 Anaconda3-4.2.0-Linux-x86_64.sh 位于您的桌面上,您可以:
或者
如果这不能解决您的问题,请编辑您的问题以包含以下输出:
我使用 bash 而不是 sh,脚本运行得很好!
似乎 sh 不适合与这个一起使用!