Python の再インストール --enable-unicode=ucs4 および lxml の未定義シンボル: PyUnicodeUCS2_DecodeLatin1

Python の再インストール --enable-unicode=ucs4 および lxml の未定義シンボル: PyUnicodeUCS2_DecodeLatin1

私は Ubuntu Server 14.04 を使用しています。新しい Django プロジェクトでは、./configure --enable-unicode=ucs4オプションを使用して Python をコンパイルする必要がありました。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 の再インストールは役に立ちません。

どうすれば修正できますか?

答え1

解決しました。

エラーの原因となる python dist を含むディレクトリを手動で削除しました。

sudo rm -R /usr/local/lib/python2.7 

次に、ソースから手動で python、scrapy、django を再インストールしました。

関連情報