[英]NumPy not importing in Jenkins pipeline
我正在尝试在 Windows 代理上通过 Jenkins(在 Linux 上)运行 Python 脚本。 我的代码在 Jenkins 服务器和代理机器上运行,但在运行 Jenkins 管道时失败,因为无法加载 numpy。 我检查了 mkl-service 是否已安装。
有什么想法吗?
我的詹金斯文件:
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:\Users\Ross\workspace\test>c:\Users\Ross\anaconda3\envs\test\python -c "import numpy"
c:\Users\Ross\anaconda3\envs\test\lib\site-packages\numpy\__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:\Users\Ross\anaconda3\envs\test\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "c:\Users\Ross\anaconda3\envs\test\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "c:\Users\Ross\anaconda3\envs\test\lib\site-packages\numpy\core\overrides.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()
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.