Pants pex安装错误:" FAILURE:无法检测到兼容性的合适解释器:(目标冲突:)"

时间:2015-04-02 15:13:18

标签: pants

我正在使用裤子版本0.0.32 +来自master的一些提交。

我想在Linux和MacOS支持中使用捆绑的pex发行版。 我正在使用Pants OSS repo构建pex:

git clean -fdx
PANTS_DEV=1 ./pants binary ./src/python/pants/bin:pants

我带了刚创建的文件dist / pants.pex,它在我的mac上工作正常。当我尝试在Linux环境中运行它时,它会退出并显示错误:

./pants test foo
Running Pants version square-20150331-02
...
11:53:22 00:08     [pytest]
11:53:22 00:08       [run]
                 WARN] /data/app/kochiku-worker/.pex/install/requests-2.5.3-py2.py3-none-any.whl.ed9d28acc3c467062b25b9dc2e2084d6efa8ee1e/requests-2.5.3-py2.py3-none-any.whl/requests/packages/urllib3/connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
  SecurityWarning


FAILURE: Unable to detect a suitable interpreter for compatibilities:  (Conflicting targets: )

[32m
           Waiting for background workers to finish.[0m[31m
           FAILURE[0m

我认为这里发生的是因为某种原因,裤子在Python 2.6下运行。我调查了安全性错误,看起来在python 2.7.2之前使用python版本时可能会意外跳闸。我尝试使用的机器上安装的python版本安装在/ usr / local / bin中,版本为2.7.9

2 个答案:

答案 0 :(得分:3)

确定 - 在版本0.0.32处获取该FAILURE消息时我找到了这个python_task.py代码:

def select_interpreter_for_targets(self, targets):
  """Pick an interpreter compatible with all the specified targets."""
  allowed_interpreters = OrderedSet(self.interpreter_cache.interpreters)
  targets_with_compatibilities = []  # Used only for error messages.

  # Constrain allowed_interpreters based on each target's compatibility requirements.
  for target in targets:
    if target.is_python and hasattr(target, 'compatibility') and target.compatibility:
      targets_with_compatibilities.append(target)
      compatible_with_target = list(self.interpreter_cache.matches(target.compatibility))
      allowed_interpreters &= compatible_with_target

  if not allowed_interpreters:
    # Create a helpful error message.
    unique_compatibilities = set(tuple(t.compatibility) for t in targets_with_compatibilities)
    unique_compatibilities_strs = [','.join(x) for x in unique_compatibilities if x]
    targets_with_compatibilities_strs = [str(t) for t in targets_with_compatibilities]
    raise TaskError('Unable to detect a suitable interpreter for compatibilities: %s '
                    '(Conflicting targets: %s)' % (' && '.join(unique_compatibilities_strs),
                                                   ', '.join(targets_with_compatibilities_strs)))

allowed_interpretersinterpreter_cache返回空白,该代码查看最近已更改密钥的配置值,以便引导解释程序。我猜你的仓库中有一个pants.ini配置缺少关键名称更改。

有一个工具可以检查pantsbuild仓库中陈旧的pants.ini配置密钥。你可以在pantbuild / pants repo的一个克隆中运行它,指向你自己的repo pants.ini,如下所示:

$ ./pants run src/python/pants/option/:migrate_config -- [path to your repo's pants.ini]

我最近在升级twitter / commons时这样做了。审核了更改here,工具输出如下:

$ ./pants run src/python/pants/option/:migrate_config -- ~/dev-jsirois-commons/pants.ini
...
17:53:44 00:00   [run]
17:53:44 00:00     [py]
17:53:44 00:00       [chroot]
17:53:44 00:00       [run]
Checking config file at /home/jsirois/dev-jsirois-commons/pants.ini for unmigrated keys.
Found indices in section [python-repos]. Should be indexes in section [python-repos].

17:53:44 00:00     [jvm]
17:53:44 00:00     [cpp-run]
               SUCCESS

请注意Found indices in section [python-repos]. Should be indexes in section [python-repos]。您可能也有同样的未迁移inidices密钥绊倒了。

答案 1 :(得分:1)

您可以使用环境变量PEX_VERBOSE = 1运行 - 这将为您提供有关您正在运行的Python版本的更多信息。您的系统Python也可能以某种方式错误配置为使用2.6中的库。

作为核选项,您可以尝试https://github.com/wickman/python-bootstrap/blob/master/bootstrap_python.sh来查看是否有助于修复您的python环境。