首页 > 解决方案 > 无法从 Gradle 运行 python 脚本?

问题描述

我尝试了以下代码,但不确定是什么问题

task runPython(type:Exec) {
    workingDir 'C:\\Users\\adityaj\\git\\Learn\\TestProject'
    commandLine 'python', 'main.py'
}

项目层次结构

还附加了项目层次结构

下面是我的 build.gradle 文件:

plugins {
    id 'groovy'
    id 'com.gradle.plugin-publish' version '0.9.10'
    id 'eclipse'
}
apply plugin: 'eclipse'
//apply plugin: 'py-build'

repositories { 
    jcenter()
}

dependencies {
  testCompile 'pypi:Werkzeug:0.7'
  testCompile 'pypi:Jinja2:2.4'
  testCompile 'pypi:itsdangerous:0.21'
  testCompile 'pypi:click:2.0'
}

task runPython(type:Exec) {
    workingDir 'C:\\Users\\adityaj\\git\\Learn\\TestProject'
    commandLine 'python', 'main.py'
}
test {
    testLogging {
        events 'skipped', 'failed', 'standard_error'
        exceptionFormat 'full'
    }
}

标签: pythonpython-3.xpython-2.7gradlebuild.gradle

解决方案


推荐阅读