未定义符号:尝试安装 psycopg2 时 PyUnicodeUCS2_Decode
我尝试在 ubuntu 9.10 64 位上安装 psycopg2 时遇到错误。
错误是:
>>> 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
我尝试从 http://initd.org/pub/software/ 下载软件包psycopg/ 并安装它。我也尝试过使用 easy_install 。
安装过程中没有错误。
这很奇怪,因为我的 python (2.6.2) 是用 UCS4 编译的,所以安装应该可以正常工作。
任何帮助将不胜感激。
干杯
I'm getting an error whilst trying to install psycopg2 on ubuntu 9.10 64 bit.
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.
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.
Any help would be appreciated.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
修好了。
我必须使用 --enable-unicode=ucs4 重新编译 python。
仍然不清楚为什么 ubuntu 上的默认版本使用 ucs4。
fixed it.
I had to recompile python with --enable-unicode=ucs4.
Still not clear why as the default version on ubuntu uses ucs4.
就像你说的,你的Python已经构建成UCS4了。但是您尝试安装的 psycopg2 是针对 Python 构建的 UCS2 构建的。找到一个或针对 UCS4 构建一个。
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.
从
bx-python
导入bx.intervals
时,我遇到了同样的错误:但是,我使用的 python 版本已经用
ucs4
编译。显然,bx-python 是针对使用 ucs2 编译的 python 版本构建的。所以我必须按照OP描述的相反方式重新编译python:./configure --enable-unicode=ucs2
。I had the same error when importing
bx.intervals
frombx-python
:However, the python version I was using was already compiled with
ucs4
. Apparently,bx-python
was built against a python version that was compiled withucs2
. So I had to recompile python in the opposite way described by the OP:./configure --enable-unicode=ucs2
.就我而言,使用 bash shell 没有任何问题,而使用 csh 则面临这个问题。实现了安装了多个版本的python。 /usr/local/bin 中的默认值有效,而 /bin 中的默认值则显示了该问题。重点是,在您认为需要使用管理员帮助重新编译之前,请检查您是否安装了任何替代版本的 python。
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.