Import numpy时,会报下面的错误python
/home/spyros/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS2_FromObjectbash
忘了截图,大概就是PyUnicodeUCS2引起的错误,提示我某些c扩展编译有问题。但是天地良心啊,我都是直接pip装的T_Tapp
解决路径:python2.7
直到我发现了这个解释:ui
You can check the size of the Unicode character a Python interpreter is using by checking the value of sys.maxunicode:spa
>>> import sys >>> if sys.maxunicode > 65535: ... print 'UCS4 build' ... else: ... print 'UCS2 build'
没错,个人是UCS4 build,可是貌似那些c扩展编译的时候默认的是UCS2?code
因此须要从新编译个人python27。blog
进入python27的安装目录(天啦噜我都不知道我是第几回安装了):ip
/home/pangxiaoyi/app/Python-2.7.13ssl
注:这里能够用sys.path来打印
./configure --enable-unicode=ucs4 --with-ssl
make
sudo make install
而后再从新sudo pip install numpy以及pandas
(numpy会影响pandas,因此要重装)