无法在 virtualenv 中安装软件包

Can't install package inside virtualenv

我有以下环境:

Linux Mint17.1 预装 python 2.7.6.

我为 python 3.3.5

安装了一个替代安装

使用 python 3.3 我创建了一个 virtualenv

我正在尝试在虚拟环境中安装 TA-Lib,但没有成功。

如果我尝试安装:

./easy_install TA-Lib

我收到以下错误:

Searching for TA-Lib
Reading https://pypi.python.org/simple/TA-Lib/
Reading http://github.com/mrjbq7/ta-lib
Reading https://github.com/mrjbq7/ta-lib/releases
Best match: TA-Lib 0.4.8
Downloading https://github.com/mrjbq7/ta-lib/archive/TA_Lib-0.4.8.zip
Processing TA_Lib-0.4.8.zip
Writing /tmp/easy_install-67a3vk/ta-lib-TA_Lib-0.4.8/setup.cfg
Running ta-lib-TA_Lib-0.4.8/setup.py -q bdist_egg --dist-dir/tmp/easy_install-67a3vk/ta-lib-TA_Lib-0.4.8/egg-dist-tmp-w24p9n
/tmp/easy_install-67a3vk/ta-lib-TA_Lib-0.4.8/setup.py:49: UserWarning: Cannot find ta-lib library, installation may fail.
  warnings.warn('Cannot find ta-lib library, installation may fail.')
talib/common.c:314:28: fatal error: ta-lib/ta_defs.h: No such file or directory
 #include "ta-lib/ta_defs.h"
                        ^
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1

如果我尝试安装:

./pip install https://github.com/mrjbq7/ta-lib/archive/TA_Lib-0.4.8.tar.gz 

我收到以下错误:

Downloading/unpacking https://github.com/mrjbq7/ta-lib/archive/TA_Lib-0.4.8.tar.gz
  Downloading TA_Lib-0.4.8.tar.gz (unknown size): 544kB downloaded
  Running setup.py (path:/tmp/pip-rxvyyh-build/setup.py) egg_info for package from https://github.com/mrjbq7/ta-lib/archive/TA_Lib-0.4.8.tar.gz
/tmp/pip-rxvyyh-build/setup.py:49: UserWarning: Cannot find ta-lib library, installation may fail.
  warnings.warn('Cannot find ta-lib library, installation may fail.')

Installing collected packages: TA-Lib
Running setup.py install for TA-Lib

...removed to make post shorter...

compilation terminated.

/tmp/pip-rxvyyh-build/setup.py:49: UserWarning: Cannot find ta-lib library, installation may fail.

 warnings.warn('Cannot find ta-lib library, installation may fail.')

error: command 'gcc' failed with exit status 1

所以基本上两种方法都会导致最终错误:

command 'gcc' failed with exit status 1

我在 virtualenv 中安装其他包如 numpy、pandas、matplotlib 等没有问题。只是 TA-Lib 不起作用。

您没有安装底层的ta-lib 库。您可以在项目网站上找到更多信息 https://github.com/mrjbq7/ta-lib :

Sometimes installation will produce build errors like this: func.c:256:28: fatal error: ta-lib/ta_libc.h: No such file or directory compilation terminated.

This typically means that it can't find the underlying TA-Lib library, a dependency which needs to be installed.