无法在亚马逊 sagemaker 上安装 ta-lib

can't install ta-lib on amazon sagemaker

我无法在 amazon sage maker 上安装 TA-LIB; 错误很奇怪:

Making install in src
/bin/sh: line 17: cd: src: Not a directory
make: *** [install-recursive] Error 1 
bash-4.2$ ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... gfortran
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether gfortran accepts -g... yes
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gfortran option to produce PIC... -fPIC
checking if gfortran PIC flag -fPIC works... yes
checking if gfortran static flag -static works... no
checking if gfortran supports -c -o file.o... yes
checking whether the gfortran linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for dlopen in -ldl... yes
checking for pthread_create in -lpthread... yes
checking for ANSI C header files... (cached) yes
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking for inttypes.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking wchar.h usability... yes
checking wchar.h presence... yes
checking for wchar.h... yes
checking wctype.h usability... yes
checking wctype.h presence... yes
checking for wctype.h... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for working volatile... yes
checking for ptrdiff_t... yes
checking return type of signal handlers... void
checking for working strcoll... yes
checking for strftime... yes
checking for working strtod... yes
checking for vprintf... yes
checking for _doprnt... no
checking for floor... no
checking for isascii... yes
checking for localeconv... yes
checking for mblen... yes
checking for memmove... yes
checking for memset... yes
checking for modf... yes
checking for pow... no
checking for sqrt... no
checking for strcasecmp... yes
checking for strchr... yes
checking for strerror... yes
checking for strncasecmp... yes
checking for strrchr... yes
checking for strstr... yes
checking for strtol... yes
checking for strtoul... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/ta_abstract/Makefile
config.status: creating src/ta_common/Makefile
config.status: creating src/ta_func/Makefile
config.status: creating src/tools/Makefile
config.status: creating src/tools/gen_code/Makefile
config.status: creating src/tools/ta_regtest/Makefile
config.status: creating ta-lib-config
config.status: creating ta-lib.spec
config.status: creating ta-lib.dpkg
config.status: creating include/ta_config.h
config.status: include/ta_config.h is unchanged
config.status: executing depfiles commands
bash-4.2$ make
Making all in src
make[1]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src'
Making all in ta_abstract
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/ta_abstract'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/ta_abstract'
Making all in ta_common
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/ta_common'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/ta_common'
Making all in ta_func
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/ta_func'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/ta_func'
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src'
make[1]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src'
Making all in src/tools
make[1]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools'
Making all in gen_code
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools/gen_code'
make  gen_code
make[3]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools/gen_code'
make[3]: `gen_code' is up to date.
make[3]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools/gen_code'
cp gen_code ../../../bin
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools/gen_code'
Making all in ta_regtest
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools/ta_regtest'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools/ta_regtest'
make[2]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools'
make[1]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib/src/tools'
make[1]: Entering directory `/home/sagemaker-user/cache/trading-strat/ta-lib'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/home/sagemaker-user/cache/trading-strat/ta-lib'
bash-4.2$ sudo make install 
Making install in src
/bin/sh: line 17: cd: src: Not a directory
make: *** [install-recursive] Error 1 

正如在 TA-Lib 的 python 包装项目 issue pages 中所讨论的那样,可以将 ta-lib 安装到允许使用当前用户权限写入的文件夹:

mkdir ~/ta-lib-bin
./configure --prefix=~/ta-lib-bin
make
make install

然后指示包装器在该文件夹中搜索 TA-Lib headers 和二进制文件:

export TA_INCLUDE_PATH=~/ta-lib-bin/include
export TA_LIBRARY_PATH=~/ta-lib-bin/lib
pip install ta-lib

这解决了问题。