2013-01-02 30 views
1

當我嘗試使用Python和Cython的包裝器爲Python安裝ta-lib(原始爲C語言的技術分析庫)時,出現錯誤消息「必須使用啓用unicode的python「。我已經嘗試了谷歌搜索無濟於事。TA-Lib安裝錯誤:必須在啓用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 
+0

@Ben你救了我的一天。讓它成爲一個答案,我會upvote它。 – Slava

+0

當然:)很高興它是有用的。 評論已移至答案。 – BenB

回答

0

你的Python二進制文件使用Unicode禁用(configure --enable_unicode=no)編譯。 NumPy 需要啓用Unicode支持的Python版本。

你將不得不安裝一個啓用它(默認)。

如果你發現你的Python具有畢竟支持Unicode(運行python,類型print u''你沒有錯誤),然後構建系統未能從C:\Python27\include拿起Python的C頭文件來代替。具體來說,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). */ 
+0

我認爲我的Python確實啓用了unicode,如果確實存在後一個問題,您是否有任何解決方法? – user1943079

+0

@ user1943079:對不起,Windows編譯系統根本就不是我的專長。 –

0

我不知道你有多大的控制在代碼 - 但嘗試使用numpy的/ ndarrayobject.h建立自己的代碼,解決辦法是#在包含ndarrayobject頭之前包含「Python.h」。

相關問題