团队,请求模块是没有找到的Python脚本,虽然它是安装.所以它是一些路径,我需要告诉Python脚本看?我正试图运行Python上的Jenkins容器Ubuntu的基础.
容器中的版本设置如下
python --version
Python 2.7.18
pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
uname -a
Linux code-scan-coverage-pbpbl 5.4.0-65-generic #73~18.04.1-Ubuntu SMP Tue Jan 19 09:02:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
which python
/usr/bin/python
pip install requests
jenksinfile调用python脚本
sh "pip install requests && ${workspace}/src/jenkins/ci/pba/pba_coverage_scan.sh"
result = sh(script: "python ${workspace}/src/jenkins/ci/pba/api.py",returnStdout: true).trim()
输出
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.22.0)
+ python /home/jenkins/agent/workspace/team/api.py
Traceback (most recent call last):
File "/home/jenkins/agent/workspace/team/api.py", line 2, in <module>
import json, requests, os
ImportError: No module named requests
python脚本是
import json, requests, os
def stuff_api():
...
1条答案
按热度按时间0md85ypi1#
我只是不得不这样做,比如安装python2,然后pip2请求。