没有从Jenkins外壳正确加载Python模块

qyzbxkaa  于 2022-10-06  发布在  Jenkins
关注(0)|答案(1)|浏览(162)

我已经配置了一个Conda环境并创建了Python项目。我正在使用Jenkins自由式工作进行项目测试。从Jenkins外壳激活了一个Conda环境,并获取找不到模块错误,已将所有必需的模块安装到此环境中。

仅供参考,当从终端工作区执行pytest server/命令时,测试用例工作正常。

Jenkins壳牌命令


# !/bin/bash

source /home/user/anaconda3/etc/profile.d/conda.sh
conda activate Unit-Test
pip list
pytest server/

使用pip list命令,我尝试从终端和Jenkins Shell检查env中安装的模块,发现从Jenkins Shell检查时缺少一些库。

已检查删除Jenkins作业缓存并创建了要检查的新作业,但问题仍然存在。我还试图一次又一次地安装缺失的库,但仍然存在相同的问题。

Jenkins外壳中缺少下列库:(差异)

asttokens
backcall
debugpy
decorator
executing 
ipykernel
pickleshare
psutil
pure-eval
Pygments
python-dateutil

我没有直接使用这些库,但boto3使用python-datutil作为支持,我收到错误消息:

import boto3
    from boto3.session import Session
    import botocore.session
    import botocore.client
    from botocore import waiter, xform_name
    from botocore.docs.docstring import WaiterDocstring
    from botocore.docs.service import ServiceDocumenter
    from botocore.docs.bcdoc.restdoc import DocumentStructure
    from botocore.compat import OrderedDict
    from dateutil.tz import tzlocal
ModuleNotFoundError: No module named 'dateutil'

我没有得到这个问题的任何理由。

需要帮助,请提出建议

yruzcnhs

yruzcnhs1#

为什么不在作业运行过程中安装所有模块?

pip安装-r要求.txt

定义Requirements s.txt中的所有要求。

相关问题