Executing python script from Jenkins job giving 'SyntaxError: invalid syntax' error
Executing python script from Jenkins job giving 'SyntaxError: invalid syntax' error
下面是我的 python 脚本的片段,运行 来自 pycharm 没问题,但如果 运行 来自 Jenkins 作业的 执行 shell 作业失败,错误提示 SyntaxError: invalid syntax at CURRENT_MONTH: Final = "cur_mon"
from typing import Final
CURRENT_MONTH: Final = "cur_mon"
LAST_MONTH: Final = "last_mon"
data_timeline = [CURRENT_MONTH, LAST_MONTH]
Jekins 作业中使用的命令是 python my_file.py
和 pyhton3 my_file.py
。在这两种情况下,它都失败并出现相同的错误。
请告知这里可能出了什么问题。
你的 Jenkins 是 运行 Python < 3.6
。变量注解语法进来了 Python 3.6
:
https://www.python.org/dev/peps/pep-0526/
此外,Final
在 Python 3.8
中被引入(但如果缺少它,当然会引发 ImportError
而不是 SyntaxError
):
下面是我的 python 脚本的片段,运行 来自 pycharm 没问题,但如果 运行 来自 Jenkins 作业的 执行 shell 作业失败,错误提示 SyntaxError: invalid syntax at CURRENT_MONTH: Final = "cur_mon"
from typing import Final
CURRENT_MONTH: Final = "cur_mon"
LAST_MONTH: Final = "last_mon"
data_timeline = [CURRENT_MONTH, LAST_MONTH]
Jekins 作业中使用的命令是 python my_file.py
和 pyhton3 my_file.py
。在这两种情况下,它都失败并出现相同的错误。
请告知这里可能出了什么问题。
你的 Jenkins 是 运行 Python < 3.6
。变量注解语法进来了 Python 3.6
:
https://www.python.org/dev/peps/pep-0526/
此外,Final
在 Python 3.8
中被引入(但如果缺少它,当然会引发 ImportError
而不是 SyntaxError
):