簡體   English   中英

從 Jenkins 作業執行 python 腳本給出“SyntaxError:無效語法”錯誤

[英]Executing python script from Jenkins job giving 'SyntaxError: invalid syntax' error

Below is the snippet from my python script which runs fine from pycharm but if run from Jenkins job's Execute shell the job is failing with error saying 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.pypyhton3 my_file.py 在這兩種情況下,它都失敗並出現相同的錯誤。

請告知這里可能出了什么問題。

您的 Jenkins 正在運行 Python < 3.6 變量注釋語法出現在 Python 3.6中:

https://www.python.org/dev/peps/pep-0526/

此外, Final在 Python 3.8中引入(但缺少它當然會引發ImportError而不是SyntaxError ):

https://www.python.org/dev/peps/pep-0591/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM