windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书

问题详情 

 TA-Lib (mrjbq7.github.io)

TA-Lib (mrjbq7.github.io)  看这个

mrjbq7/ta-lib: Python wrapper for TA-Lib (http://ta-lib.org/). (github.com)

1 You can install from PyPI:失败了!

$ python3 -m pip install TA-Lib

Or checkout the sources and run setup.py yourself:

$ python setup.py install

It also appears possible to install via Conda Forge:

$ conda install -c conda-forge ta-lib

######################################3333

Installation

You can install from PyPI:

$ pip install TA-Lib

Or checkout the sources and run setup.py yourself:

$ python setup.py install

Troubleshooting Install Errors

func.c:256:28: fatal error: ta-lib/ta_libc.h: No such file or directory
compilation terminated.

If you get build errors like this, it typically means that it can't find the underlying TA-Lib library and needs to be installed:

Dependencies

To use TA-Lib for python, you need to have the TA-Lib already installed:

Mac OS X

$ brew install ta-lib

Windows

Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib

Linux

Download ta-lib-0.4.0-src.tar.gz and:

$ untar and cd
$ ./configure --prefix=/usr
$ make
$ sudo make install

If you build TA-Lib using make -jX it will fail but that's OK! Simply rerun make -jX followed by [sudo] make install.

Documentation Index

 #################################再次报错

(rna) ubuntu@DESKTOP-O25BSJM:/mnt/g/silicosis/sicosis/gitto/python_study/scanpy_study$ pip install TA-Lib -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
Collecting TA-Lib
  Downloading https://pypi.doubanio.com/packages/7c/56/d1360aabbf9366afdb55b5b3188314c7726adcdc3f417e62e3353801663a/TA-Lib-0.4.25.tar.gz (271 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 272.0/272.0 kB 1.2 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /home/ubuntu/anaconda3/envs/rna/lib/python3.10/site-packages (from TA-Lib) (1.23.5)
Building wheels for collected packages: TA-Lib
  Building wheel for TA-Lib (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for TA-Lib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      :77: UserWarning: Cannot find ta-lib library, installation may fail.
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/talib
      copying talib/abstract.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/deprecated.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/stream.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_abstract.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_data.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_func.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_pandas.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_polars.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/test_stream.py -> build/lib.linux-x86_64-cpython-310/talib
      copying talib/__init__.py -> build/lib.linux-x86_64-cpython-310/talib
      running build_ext
      building 'talib._ta_lib' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/talib
      gcc -pthread -B /home/ubuntu/anaconda3/envs/rna/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/ubuntu/anaconda3/envs/rna/include -fPIC -O2 -isystem /home/ubuntu/anaconda3/envs/rna/include -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/tmp/pip-build-env-e5jlx9ja/normal/lib/python3.10/site-packages/numpy/core/include -I/home/ubuntu/anaconda3/envs/rna/include/python3.10 -c talib/_ta_lib.c -o build/temp.linux-x86_64-cpython-310/talib/_ta_lib.o
      error: command 'gcc' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for TA-Lib
Failed to build TA-Lib
ERROR: Could not build wheels for TA-Lib, which is required to install pyproject.toml-based projects
(rna) ubuntu@DESKTOP-O25BSJM:/mnt/g/silicosis/sicosis/gitto/python_study/scanpy_study$ 

同样的错误:  但是不能解决问题 Failed to build ta-lib ERROR: Could not build wheels for ta-lib, which is required to install pyproject.toml-based project · Issue #566 · mrjbq7/ta-lib (github.com)

mrjbq7/ta-lib: Python wrapper for TA-Lib (http://ta-lib.org/). (github.com) 试了一下官网教程

Linux

2 Download ta-lib-0.4.0-src.tar.gz and: 还是失败  在第三步

$ tar -xzf ta-lib-0.4.0-src.tar.gz
$ cd ta-lib/
$ ./configure --prefix=/usr
$ make
$ sudo make install

 又出现问题

windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第1张图片

3 然后按照这个教程 Installation of Ta-Lib in Python: A Complete Guide for all Platforms (quantinsti.com) 

sudo apt-get -y install gcc build-essential

有点像这个家伙说的一样

you need to install the c library first.
ta-lib consists of 2 parts, the C part, and the python part.

Installing the python part without the C part will fail.

The ta lib python docs have a decent instruction - alternatively you can use the quick install script (./setup.sh -i) to install the c part (this will take a while on a raspberry).

You can also use the docker image we provide to get started with freqtrade.

 但是又失败了

windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第2张图片

先安装 gcc 再来安装talib

4 更新一下apt试试  但是也失败了!

sudo apt-get -y install gcc build-essential

apt - Failed to fetch - Installation errors - Ask Ubuntu

 windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第3张图片windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第4张图片

 5 把关了也还是这样的报错

6加入public key试试看 需要才能加入 不知道为啥 国内加不了 

apt - How do I fix the GPG error "NO_PUBKEY"? - Ask Ubuntu

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32

 windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第5张图片

7 现在再来更新一下apt试试 成功了!同时gcc也安装好了

sudo apt-get -y install gcc build-essential

8重新开始第二步试试2 Download ta-lib-0.4.0-src.tar.gz and:  这次就成功了 就是编译的时间有点长  

$ tar -xzf ta-lib-0.4.0-src.tar.gz
$ cd ta-lib/
$ ./configure --prefix=/usr
$ make
$ sudo make install

windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第6张图片

9 第八步只是编译成功,还需要安装才算真正成功 ,否则用不起来  但是这一步又失败了!!!安装不成功 ,但是重启 重新安装就成功了!!!!!!就可以使用python导入talib了

Installation of Ta-Lib in Python: A Complete Guide for all Platforms (quantinsti.com)

pip install ta-lib

windows中Linux ubuntu子系统 安装talib 编译talib python 安装 talib 报错 - 简书_第7张图片

 

 

Execute the following commands in terminal

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 

where  is your missing public key for repository, e.g. 8BAF9A6F.

Then update

sudo apt-get update

ALTERNATE METHOD:

sudo gpg --keyserver pgpkeys.mit.edu --recv-key  
sudo gpg -a --export  | sudo apt-key add -
sudo apt-get update

Note that when you import a key like this using apt-key you are telling the system that you trust the key you're importing to sign software your system will be using. Do not do this unless you're sure the key is really the key of the package distributor.

 或者 TA-Lib (mrjbq7.github.io)

Linux

Download ta-lib-0.4.0-src.tar.gz and:

$ untar and cd
$ ./configure --prefix=/usr
$ make
$ sudo make install

你可能感兴趣的:(纸上得来终觉浅,python,开发语言,linux)