[英]python3 --version shows "NameError: name 'python3' is not defined"
[英]NameError: name 'python3' is not defined [Jenkins]
我的任务很简单。 我已经编写了一个脚本job.sh
来调用python脚本
#!/bin/bash
python3 pythonscript/script.py
我希望此script.py
每小时运行一次,因此我在Jenkins的帮助下并在项目中配置了job.sh
独立运行job.sh
可以正常工作,但是在Jenkins中运行相同的文件时会显示错误:
NameError: name 'python3' is not defined
Build step 'Execute shell' marked build as failure
Finished: FAILURE
script.py中的内容:
for i in range(30):
print("PRINTING FROM PYTHON SCRIPT")
有两个问题:
1) How to resolve the above error
2) The Jenkins job runs in a different folder lets say `(jenkins/jobs/job131.sh)` and my `script.py` is somewhere else `(pythonscript/script.sh)`. How to give the absolute path to my script so that `job.sh` will invoke it without any issue.
选项1:
尝试更改shebang,使其可以与特定版本的Python一起运行
#!/usr/bin/python2.6
选项2:
尝试将其作为python2而不是python3运行
python pythonscript/script.py
您可以使用pwd
获取脚本的绝对路径。 然后,您可以将其添加到jenkins脚本中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.