问题:
服务器Linux系统原生python
为2.7.9
, 想升级运行多进程multiprocessing
【见此链接】。 想使用Anaconda2
安装python2.7.15
, 安装完成后,导入编译好的.so
文件遇到问题:
ImportError: modules/XXX.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8
Google之:
系统原生的python
为UCS2编码,Anaconda的 python
均为UCS4
, .so
文件编译时的平台为UCS2
。
比较相关的答案链接
https://stackoverflow.com/questions/11878666/python-undefined-symbol-pyunicodeucs2-decodeutf8
"on Linux all Anaconda Python packages use UCS4, more precisely: Because Anaconda Python 2 itself was compiled using the UCS4 flag, all (C extension) packages build against it, will be only compatible with a UCS4 Python 2 build. In many Linux distributions, e.g. Ubuntu, CentOS, UCS4 is used by the system Python (/usr/bin/python). You can always check this by looking at sys.maxunicode: the value 1114111 means UCS4 and 65535 means UCS2. It would be a large effort to provide an additional version of Anaconda for Linux in which all packages are build against a UCS2 compiled Python 2. "
https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/CWU07_b1VZY
我的解决方案:
卸载Ananconda
, 手动下载并安装Python 2.7.15
.