Skip to main content
 首页 » 编程设计

python之在带有 Python2.6 的 Mac 上并尝试安装 psycopg2

2025年05月04日11kerrycode

我是 Python 新手。我现在运行 Python2.6。我正在关注 Python 网站上的教程。我的问题是当我尝试按照此处的说明操作时:

http://py-psycopg.darwinports.com/

我得到了类似...

sudo port install py-psycopg 
... bunch of errors here... 
Error: The following dependencies failed to build: py-mx python24 

我运行的是 MacOS X 10.4。

我该怎么做?

如有任何回复,我们将不胜感激。

更新:

运行下面的代码后,我得到以下错误:

$ sudo port install py26-psycopg2 
Warning: Skipping upgrade since openssl 0.9.8k_0 >= openssl 0.9.8k_0, even though installed variants "" do not match "+darwin". Use 'upgrade --enforce-variants' to switch to the requested variants. 
    Warning: Skipping upgrade since readline 6.0.000_1 >= readline 6.0.000_1, even though installed variants "" do not match "+darwin". Use 'upgrade --enforce-variants' to switch to the requested variants. 
    --->  Computing dependencies for py26-psycopg2 
    --->  Building python26 
    Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.2" && /usr/bin/make all MAKE="/usr/bin/make CC=/usr/bin/gcc-4.0" " returned error 2 
    Command output: /usr/bin/install -c -d -m 755 Python.framework/Versions/2.6 
    if test ""; then \ 
            /usr/bin/gcc-4.0 -o Python.framework/Versions/2.6/Python  -dynamiclib \ 
                    -isysroot "" \ 
                    -all_load libpython2.6.a -Wl,-single_module \ 
                    -install_name /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python \ 
                    -compatibility_version 2.6 \ 
                    -current_version 2.6; \ 
            else \ 
            /usr/bin/libtool -o Python.framework/Versions/2.6/Python -dynamic  libpython2.6.a \ 
                     -lSystem -lSystemStubs -install_name /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python -compatibility_version 2.6 -current_version 2.6 ;\ 
    fi 
    ld64 failed: in libpython2.6.a(__.SYMDEF), not a valid ppc64 mach-o file 
    /usr/bin/libtool: internal link edit command failed 
    make: *** [Python.framework/Versions/2.6/Python] Error 1 
 
    Error: The following dependencies failed to build: python26 
    Error: Status 1 encountered during processing. 

仅供引用,我安装的 python 是来自 pythong 站点的 dmg 文件。

谢谢, 温伯特

请您参考如下方法:

如果您使用的是 Python 2.6,您实际上想要构建 py26-psycopg2:

$ sudo port install py26-psycopg2 

在 MacPorts 中,py-* 包使用 Python 2.4 构建,py25-* 使用 Python 2.5,py26-* 使用 Python 2.6 .