Python 重新安装 --enable-unicode=ucs4 和 lxml 未定义符号:PyUnicodeUCS2_DecodeLatin1

Python reinstallation --enable-unicode=ucs4 and lxml undefined symbol: PyUnicodeUCS2_DecodeLatin1

我正在使用 Ubuntu 服务器 14.04。 我的新 django 项目 python 需要 ./configure --enable-unicode=ucs4 选项。我用 ucs4 重新安装了 python。

现在,当我尝试 运行 scrapy spider 时,出现如下错误:

ImportError: /usr/local/lib/python2.7/site-packages/lxml-3.4.2-py2.7-linux-x86_64.egg/lxml/etree.so: undefined symbol: PyUnicodeUCS2_DecodeLatin1

然后我再次尝试重新安装 python 但出现错误:

Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1

然后我尝试重新安装 libxml,但也有错误:

/usr/bin/ld: /usr/local/lib/python2.7/config/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/python2.7/config/libpython2.7.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

重新安装 Scrapy 没有帮助。

求求你帮忙!

我解决了。 也许这对某人有用。 我使用 sudo rm -R /usr/local/lib/python2.7 文件夹手动删除 python dist,这会导致错误。 然后我从源手动重新安装 python、scrapy 和 django。