python 未定义符号:尝试安装 psycopg2 时 PyUnicodeUCS2_Decode

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2584198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-04 01:00:05  来源:igfitidea点击:

undefined symbol: PyUnicodeUCS2_Decode whilst trying to install psycopg2

pythonpsycopg2

提问by Marco Fucci

I'm getting an error whilst trying to install psycopg2 on ubuntu 9.10 64 bit.

尝试在 ubuntu 9.10 64 位上安装 psycopg2 时出现错误。

The error is:

错误是:

>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "psycopg2/__init__.py", line 69, in <module>
    from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: psycopg2/_psycopg.so: undefined symbol: PyUnicodeUCS2_Decode

I've tried downloading the package from http://initd.org/pub/software/psycopg/and installing it. I've tried by using easy_install too.

我试过从http://initd.org/pub/software/psycopg/下载软件包并安装它。我也尝试过使用 easy_install。

No error during the installation.

安装过程中没有错误。

It's quite weird as my python (2.6.2) has been compiled with UCS4 and so the installation should just work without problems.

这很奇怪,因为我的 python (2.6.2) 是用 UCS4 编译的,所以安装应该没有问题。

Any help would be appreciated.

任何帮助,将不胜感激。

Cheers

干杯

回答by Marco Fucci

fixed it.

解决它。

I had to recompile python with --enable-unicode=ucs4.

我不得不用 --enable-unicode=ucs4 重新编译 python。

Still not clear why as the default version on ubuntu uses ucs4.

仍然不清楚为什么 ubuntu 上的默认版本使用 ucs4。

回答by Ignacio Vazquez-Abrams

Like you say, your Python has been built UCS4. But the psycopg2 you're trying to install has been built against a Python built UCS2. Find one or build one against UCS4.

就像你说的,你的 Python 已经构建了 UCS4。但是您尝试安装的 psycopg2 是针对 Python 构建的UCS2构建的。针对 UCS4 查找或构建一个。

回答by user13434221

In my case, using bash shell I had no issue and with csh faced this issue. Realized have multiple version of python installed. one defaulting in /usr/local/bin worked vs one in /bin exhibited the issue. Point being before you think you need to recompile with admin help check if you have any alternate version of python installed.

就我而言,使用 bash shell 我没有问题,而使用 csh 时遇到了这个问题。实现安装了多个版本的python。/usr/local/bin 中的一个默认值有效,而 /bin 中的一个默认值显示了该问题。在您认为需要使用管理员帮助重新编译之前,请先检查是否安装了任何替代版本的 python。