问题
when I try to install ta-lib(a technical analysis library coded originally in C) for Python using a wrapper for Python and Cython, I get an error message saying "Must use python with unicode enabled". I have already tried googling to no avail.
Here's the full error message:
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
回答1:
Your Python binary was compiled with Unicode disabled (configure --enable_unicode=no
). NumPy requires a Python build with Unicode support enabled.
You'll have to install one that does have it enabled (the default).
If you find your Python has Unicode enabled after all (run python
, type print u''
and you get no errors), then the build system is failing to pick up the Python C headers from C:\Python27\include
instead. Specifically, the pyconfig.h
file could be missing:
$ 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). */
回答2:
I'm not sure how much control you have over the code -- but trying to build my own code using numpy/ndarrayobject.h, the solution was to #include "Python.h" before including the ndarrayobject header.
来源:https://stackoverflow.com/questions/14123593/ta-lib-installation-error-must-use-python-with-unicode-enabled