NumPy未在Jenkins管道中导入



我正试图通过Jenkins(在Linux上(在Windows代理上运行Python脚本。我的代码在Jenkins服务器和代理机器上运行,但在运行Jenkins管道时失败,因为无法加载numpy。我检查了mkl服务是否已安装。

有什么想法吗?

我的詹金斯档案:

pipeline {
agent none
options {
skipStagesAfterUnstable()
}
stages {
stage('Build') {
agent {
docker {
image 'python:2-alpine'
}
}
steps {
sh 'python -m py_compile test.py'
}
}
stage('Deliver') {
agent {label 'CI-W10-Box'}
steps {
bat 'conda env remove -y --name test'
bat 'conda env create' // Build environment based on environment.yml
bat 'conda activate test'
bat 'c:\Users\Ross\anaconda3\envs\test\python -c "import numpy"'
}
post {
success {
sh 'ls dist/gh'
archiveArtifacts 'dist/gh'
}
always {
cleanWs()
}
}
}
}

}

我使用简单的命令python -c "import numpy"来隔离问题,但它不加载。错误消息为:

C:UsersRossworkspacetest>c:UsersRossanaconda3envstestpython -c "import numpy" 
c:UsersRossanaconda3envstestlibsite-packagesnumpy__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "c:UsersRossanaconda3envstestlibsite-packagesnumpycore__init__.py", line 22, in <module>
from . import multiarray
File "c:UsersRossanaconda3envstestlibsite-packagesnumpycoremultiarray.py", line 12, in <module>
from . import overrides
File "c:UsersRossanaconda3envstestlibsite-packagesnumpycoreoverrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

此外,当我尝试python -c "import mkl"时,我会得到ImportError: DLL load failed while importing _mklinit: The specified module could not be found.。我想知道是否有一个PATH变量需要设置或类似的东西。

修复方法是添加环境变量CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1,如下所示:

stage('Deliver') {
agent {label 'CI-W10-Box'}
environment {
CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
}
steps {
bat 'conda env remove -y --name test'
bat 'conda env create' // Build environment based on environment.yml
bat 'conda activate test'
bat 'c:\Users\Ross\anaconda3\envs\test\Scripts\pyinstaller --onefile gh-debug.spec'
//bat 'c:\Users\Ross\anaconda3\envs\test\python -c "import mkl"'
}
post {
success {
sh 'ls dist/gh'
archiveArtifacts 'dist/gh'
}
always {
cleanWs()
}
}
}

最新更新