1

当我尝试使用 Python 和 Cython 的包装器为 Python 安装 ta-lib(最初用 C 编码的技术分析库)时,我收到一条错误消息,提示“必须使用启用了 unicode 的 python”。我已经尝试谷歌搜索无济于事。

这是完整的错误消息:

    C:\Python27\Lib\site-packages\ta-lib-master>python setup.py install
    running install
    running build
    running build_ext
    skipping 'talib.c' Cython extension (up-to-date)
    building 'talib' extension
    C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
    /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packages\numpy\core\include -Ic:\ms
    ys\1.0\local\include -IC:\Python27\include -IC:\Python27\PC /Tctalib.c /Fobuild\
    temp.win32-2.7\Release\talib.obj
    talib.c
    c:\python27\lib\site-packages\numpy\core\include\numpy\npy_common.h(85) : fatal
    error C1189: #error :  Must use Python with unicode enabled.
    error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex
    e"' failed with exit status 2
4

2 回答 2

0

您的 Python 二进制文件是在禁用 Unicode 的情况下编译的 ( configure --enable_unicode=no)。NumPy需要启用 Unicode 支持的 Python 构建。

您必须安装一个启用它的软件(默认)。

如果你发现你的 Python 已经启用了 Unicode(运行python,输入print u''并且你没有收到任何错误),那么构建系统将无法从中获取 Python C 头文件C:\Python27\include。具体来说,该pyconfig.h文件可能会丢失:

$ grep -i unicode /usr/include/python2.6/pyconfig.h
   Include/unicodeobject.h). */
/* Define as the integral type used for Unicode representation. */
#define PY_UNICODE_TYPE unsigned long
/* Define as the size of the unicode type. */
#define Py_UNICODE_SIZE 4
/* Define if you want to have a Unicode type. */
#define Py_USING_UNICODE 1
   supplied by Python itself. (see Include/unicodectype.h). */
于 2013-01-02T14:22:17.940 回答
0

我不确定您对代码有多少控制权——但尝试使用 numpy/ndarrayobject.h 构建我自己的代码,解决方案是在包含 ndarrayobject 标头之前 #include "Python.h"。

于 2016-02-04T17:57:30.860 回答