【问题标题】:pypokereval library configure script fails with "No python development environments found"pypokereval 库配置脚本失败并显示“未找到 python 开发环境”
【发布时间】:2013-12-18 18:16:55
【问题描述】:

我正在尝试为 python2.7 编译 pypoker-eval-138.0 库(默认在 mint linux 上):

因此,当通过./configure 运行配置脚本时,我收到有关 python 解释器版本的错误:

    ...snip...
checking for a Python interpreter with version =2.3... done
checking for a Python interpreter with version =2.4... done
checking for a Python interpreter with version =2.5... done
checking for a Python interpreter with version =2.6... done
configure: error: No python development environments found

我安装的python版本:

ls /usr/bin/python*
/usr/bin/python (/usr/bin/python -> python2.7)
/usr/bin/python2-dbg-config
/usr/bin/python2               /usr/bin/python3
/usr/bin/python2.7             /usr/bin/python3.3
/usr/bin/python2.7-config      /usr/bin/python3.3m
/usr/bin/python2.7-dbg         /usr/bin/python3m
/usr/bin/python2.7-dbg-config  /usr/bin/python-config
/usr/bin/python2-config        /usr/bin/python-dbg
/usr/bin/python2-dbg           /usr/bin/python-dbg-config

我也尝试过./configure PYTHON="/usr/bin/python2.7" 和类似的,但在上述问题上遇到了变体:

 ...snip..
 checking whether to enable maintainer-specific portions of Makefiles... no
 checking whether /usr/bin/python2.7 version =2.3... configure: error: too old

为了解决这个问题,我花费了大量时间来尝试更改 aclocal/autoconf 设置,但对应该做什么不是很熟悉。我尝试编辑以下 .m4 文件,但失败程度不同:

 ls ./aclocal.m4 ./config/*
 ./aclocal.m4           ./config/install-sh      ./config/ltsugar.m4
 ./config/ccpython.m4   ./config/libtool.m4      ./config/ltversion.m4
 ./config/config.guess  ./config/ltmain.sh       ./config/missing
 ./config/config.sub    ./config/lt~obsolete.m4  ./config/py-compile
 ./config/depcomp       ./config/ltoptions.m4    ./config/python.m4

例如./config/ccpython.m4:

 ...snip..
 AC_DEFUN([ALL_CC_PYTHON],
 [ 
 m4_define([_AM_PYTHON_INTERPRETER_LIST], [python2.6 python2.5 python2.4 python2.3])
 PYTHONS=''
 found_one=''
 _ONE_CC_PYTHON([=2.3], [2_3])
 if test -f "$PYTHON" ; then found_one=$PYTHON ; PYTHONS="$PYTHON $PYTHONS" ; fi
 unset PYTHON
 ...snip..

我的问题是,具体来说:如何为 2.7 编译一个具有仅支持最高 2.6 的配置脚本的 python 模块?我是否必须重新生成配置脚本,或者我可以将一些标志或变量传递给配置脚本以强制构建 2.7?

非常感谢!

【问题讨论】:

    标签: python linux python-2.7 configure automake


    【解决方案1】:

    你可以尝试从http://www.python.org/download/releases/2.6.9/源安装python2.6

    或试用 pyenv https://github.com/yyuu/pyenv

    【讨论】:

    • 这两个选项对我来说都不是糟糕的选择。现在尝试 pyenv,如果它成功了,我会告诉你的。但是,您知道是否可以为 2.7 配置安装吗?
    【解决方案2】:

    好的,这是一个挑战(可以为声誉做些什么?:)。

    提示在更新日志中

        * config/python.m4 (AM_PATH_PYTHON): Added python2.6 support.
    
        * config/ccpython.m4 (ALL_CC_PYTHON): Added python2.6 support.
    

    所以它应该只修复这些文件以支持新的 python 版本。我刚刚用 python 2.7 替换了 python 2.5,用 autoreconf 重新配置,它工作了。请参阅下面的完整补丁。

    要使其正常工作,请确保已安装以下软件包:

    $ apt-get install python-dev autoconf pkg-config
    

    应用下面的补丁并运行

    $ autoreconf
    $ ./configure
    $ make
    

    这是补丁(好吧,我也必须更改 Makefile.am):

    diff --git a/Makefile.am b/Makefile.am
    index c16df82..7d66971 100644
    --- a/Makefile.am
    +++ b/Makefile.am
    @@ -40,12 +40,12 @@ _pokereval_2_6_la_LIBADD = ${PYTHON2_6_LIBS} ${POKER_EVAL_LIBS}
     _pokereval_2_6_la_CFLAGS = ${PYTHON2_6_CFLAGS} ${POKER_EVAL_CFLAGS} -DPYTHON_VERSION=\"2_6\" -D'VERSION_NAME(w)=w\#\#2_
     endif
    
    -if PYTHON_2_5
    -py2_5exec_LTLIBRARIES = _pokereval_2_5.la
    -_pokereval_2_5_la_SOURCES = pypokereval.c
    -_pokereval_2_5_la_LDFLAGS = -module -no-undefined -version-info 1:0:0
    -_pokereval_2_5_la_LIBADD = ${PYTHON2_5_LIBS} ${POKER_EVAL_LIBS}
    -_pokereval_2_5_la_CFLAGS = ${PYTHON2_5_CFLAGS} ${POKER_EVAL_CFLAGS} -DPYTHON_VERSION=\"2_5\" -D'VERSION_NAME(w)=w\#\#2_
    +if PYTHON_2_7
    +py2_7exec_LTLIBRARIES = _pokereval_2_7.la
    +_pokereval_2_7_la_SOURCES = pypokereval.c
    +_pokereval_2_7_la_LDFLAGS = -module -no-undefined -version-info 1:0:0
    +_pokereval_2_7_la_LIBADD = ${PYTHON2_7_LIBS} ${POKER_EVAL_LIBS}
    +_pokereval_2_7_la_CFLAGS = ${PYTHON2_7_CFLAGS} ${POKER_EVAL_CFLAGS} -DPYTHON_VERSION=\"2_7\" -D'VERSION_NAME(w)=w\#\#2_
     endif
    
     if PYTHON_2_4
    diff --git a/config/ccpython.m4 b/config/ccpython.m4
    index c94cbb6..46de0db 100644
    --- a/config/ccpython.m4
    +++ b/config/ccpython.m4
    @@ -110,7 +110,7 @@ AM_CONDITIONAL([PYTHON_]$2, [test "$have_python" != "no"])
    
     AC_DEFUN([ALL_CC_PYTHON],
     [ 
    -m4_define([_AM_PYTHON_INTERPRETER_LIST], [python2.6 python2.5 python2.4 python2.3])
    +m4_define([_AM_PYTHON_INTERPRETER_LIST], [python2.6 python2.7 python2.4 python2.3])
     PYTHONS=''
     found_one=''
     _ONE_CC_PYTHON([=2.3], [2_3])
    @@ -119,7 +119,7 @@ unset PYTHON
     _ONE_CC_PYTHON([=2.4], [2_4])
     if test -f "$PYTHON" ; then found_one=$PYTHON ; PYTHONS="$PYTHON $PYTHONS" ; fi
     unset PYTHON
    -_ONE_CC_PYTHON([=2.5], [2_5])
    +_ONE_CC_PYTHON([=2.7], [2_7])
     if test -f "$PYTHON" ; then found_one=$PYTHON ; PYTHONS="$PYTHON $PYTHONS" ; fi
     unset PYTHON
     _ONE_CC_PYTHON([=2.6], [2_6])
    diff --git a/config/python.m4 b/config/python.m4
    index c8c5e30..4d0366e 100644
    --- a/config/python.m4
    +++ b/config/python.m4
    @@ -42,7 +42,7 @@ AC_DEFUN([AM_PATH_PYTHON],
       dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
       dnl in 1.5.
       m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
    -                      [python python2 python2.5 python2.6 python2.4 python2.3 python2.2 dnl
    +                      [python python2 python2.7 python2.6 python2.4 python2.3 python2.2 dnl
     python2.1 python2.0 python1.6 python1.5])
    
       m4_if([$1],[],[
    

    【讨论】:

    • 非常感谢!有效!我曾尝试过类似的补丁,但在它的几个不同方面搞砸了。你已经拯救了这一天
    • 7 年后,这正在帮助我将同一个库移植到 Python 3!
    猜你喜欢
    • 2020-04-29
    • 1970-01-01
    • 2014-08-07
    • 2016-08-14
    • 1970-01-01
    • 2021-02-17
    • 2021-02-22
    • 2015-07-15
    • 1970-01-01
    相关资源
    最近更新 更多