无法从Jenkins管道运行Python .py

时间:2019-07-30 01:05:53

标签: python shell jenkins pipeline

从Jenkins管道无法运行python脚本。 Jenkins和python脚本位于aws ec2实例上

在Jenkins Pipeline节点中添加了该代码段,jenkins能够运行make文件(这意味着它可以开始执行makefile),但是在jenkins Console Output中,它因Python模块未找到错误而出错。相同的make文件可以在ec2实例上正常运行。

which

node { stage('Deploy') { sh "(make -f /var/lib/jenkins/workspace/test-build-job/runpy)" } } ******************************************* runpy makefile: SHELL := /bin/bash run: nohup /usr/bin/python3 /var/lib/jenkins/workspace/test-build-job/aaa.py 2>&1 > aaa.out & nohup /usr/bin/python3 /var/lib/jenkins/workspace/test-build-job/bbb.py 2>&1 > bbb.out & ****************************************** Error in the console output: ModuleNotFoundError: No module named 'flask' ****************************************** Printed sys.path from py: When run on EC2: /var/lib/jenkins/workspace/test-build-job', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/home/ec2-user/.local/lib/python3.6/site-packages', '/usr/local/lib64/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages', '/usr/lib64/python3.6/dist-packages', '/usr/lib/python3.6/dist-packages /var/lib/jenkins/workspace/test-build-job', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/usr/local/lib64/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages', '/usr/lib64/python3.6/dist-packages', '/usr/lib/python3.6/dist-packages 在jenkins比赛中丢失(我可以在此位置看到Flask)

---使用-------'/home/ec2-user/.local/lib/python3.6/site-packages'

在.py中添加了路径

没有帮助,仍然看到模块未找到错误:(

1 个答案:

答案 0 :(得分:0)

问题是,没有安装烧瓶模块,正在运行代码。

我假设代码在master上运行,因为我在代码中看不到任何代理声明。因此,您的jenkins主站似乎没有安装所需的模块。