• Jenkins自动部署svn上去的selenium+python项目,执行报错找不到模块


    在本地执行selenium成功,但是svn到Jenkins后,执行报错,找不到模块

    具体日志如下:

    Started by user admin
    Running as SYSTEM
    Building in workspace C:\Users\Administrator\.jenkins\workspace\shopsvn
    Updating svn://139.159.149.114/machong/Shop_V21 at revision '2022-03-05T10:55:40.882 +0800' --quiet
    Using sole credentials wuxx/****** in realm ‘<svn://139.159.149.114:3690> ea9421a4-a020-4eb3-a9d0-453ba536d2e5’
    At revision 601
    
    No changes for svn://139.159.149.114/machong/Shop_V21 since the previous build
    Script returned: 
    [shopsvn] $ cmd /c call D:\soft\apache\apache-tomcat-9.0.54\temp\jenkins1865818149553420835.bat
    
    C:\Users\Administrator\.jenkins\workspace\shopsvn>cd runCases 
    
    C:\Users\Administrator\.jenkins\workspace\shopsvn\runCases>python run.py 
    Traceback (most recent call last):
      File "run.py", line 15, in <module>
        from shop_utils.email_manager import EmailManager
    ModuleNotFoundError: No module named 'shop_utils'
    
    C:\Users\Administrator\.jenkins\workspace\shopsvn\runCases>exit 1 
    Build step 'Execute Windows batch command' marked build as failure
    Sending e-mails to: 75603083@qq.com
    Finished: FAILURE

    解决方法:
    在每个调用找不到模块的py文件,最上面加上以下代码:
    import sys
    import os
    #将项目路径加到环境变量里面
    curPath = os.path.abspath(os.path.dirname(__file__))
    rootPath = os.path.abspath(os.path.dirname(curPath) + os.path.sep + ".")
    sys.path.append(rootPath)
  • 相关阅读:
    [转]中国诗歌简史
    [转]古典诗词综述
    sqlite元数据
    hihocoder第226周:打表找规律
    理解bleu
    tensorflow代码中的一个bug
    tensorflow中的sequence_loss_by_example
    numpy二分查找
    一道贪心:加括号使算式的值最大
    kafaka可视化工具
  • 原文地址:https://www.cnblogs.com/wuxiaoxia/p/15967257.html
Copyright © 2020-2023  润新知