【问题标题】:Calling Python from Maven in a Cygwin shell在 Cygwin shell 中从 Maven 调用 Python
【发布时间】:2012-10-25 14:00:09
【问题描述】:

从 Cygwin shell(Windows 上的 bash 通过 Cygwin)使用 Maven 构建时,/usr/bin 的路径无法正确解析。

让我解释一下。 Cygwin 附带 Python,可作为 /usr/bin 的符号链接访问。 Maven 应该可以访问这个符号链接,因为它的位置在 PATH 环境变量中。 Cygwin 将 /usr/bin 添加到 PATH 环境变量中。但是,Maven 无法找到 Python。例如。

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default) on project cloud-devcloud: Command execution failed. Cannot run program "python" (in directory "C:\cygwin\home\myuser\incubator-cloudstack\tools\devcloud"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

但是有 Python:

$ which python
/usr/bin/python

虽然是符号链接。

$ ls -al /usr/bin/python
lrwxrwxrwx 1 donall Domain Users 13 Sep 19 11:38 /usr/bin/python -> python2.6.exe

Python 是符号链接的问题吗?还是说 Maven 无法访问 /usr/bin 中的文件?

【问题讨论】:

    标签: python maven cygwin


    【解决方案1】:

    看起来 maven 是作为常规的 Windows 原生应用程序运行的,而不是“支持 cygwin 的应用程序”(如果存在这种情况 :-))

    这由内部使用的路径表示,在日志中打印:C:\cygwin\home\myuser\incubator-cloudstack\tools\devcloud

    因此,来自 Maven 的调用在定位 python 可执行文件时将无法识别 cygwin 路径。一种可能的解决方案是将包含 python.exe 的目录添加到系统 PATH(这意味着,Windows PATH 变量)

    【讨论】:

    • 你确定吗?我通过符号链接复制了 python26.exe,并且脚本有效。这表明路径很好。
    • 这是我在其他程序中遇到的相关问题的解决方案。我不确定 Maven 如何处理该调用,但情况非常相似。无论如何,如果信息不准确,我深表歉意!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    相关资源
    最近更新 更多