current position:Home>Jenkins deployment project execution pipeline script prompt: Python module not found

Jenkins deployment project execution pipeline script prompt: Python module not found

2022-02-02 21:56:56 CSDN Q & A

Jenkins Deployment project perform pipeline Script hint not found python module, On the node machine It is possible to run scripts , I don't know what caused it ?

pipeline script:

stage('Prepare'){            options { timeout(time: 30, unit: 'MINUTES')  }            agent {
   
   
   
   label 'NUC_05'} /* <-------------- */            steps{                script{                    t_rv=nodesByLabel('NUC_05')                    if (t_rv.size()==0) error "Host: NUC_05 is offline"                }                /*error "debug to stop here."*/                dir('C:\\workspace\\work\\preparetestbench'){ /* <------------ */                    echo "Prepare pipeline info"                    bat "py -3 preparetest.py"                }            }        }

Error Tips :
C:\workspace\cvf_work\preparetestbench>py -3 preparetest.py
Traceback (most recent call last):
File "preparetest.py", line 28, in
import yaml
ModuleNotFoundError: No module named 'yaml'




Refer to the answer 1:

checkpoint :

  1. Check remote machine Whether to install python The library the script depends on
  2. Check whether the installation path of the library and the system environment variable are To configure

summary :
I checked that the library on the remote machine is installed , But the library installation path is not in C:\Program Files\Python3x\Lib\site-packages Next , It's installed in C:\Users\NUC\AppData\Roaming\Python\Python3x\site-packages Next , The system environment variables are not configured , therefore Jenkins When you run the script, you will be prompted that the library cannot be found .
I tried to add the actual installation path of the library to the environment variable , It doesn't seem to work , I don't know why , At present, the stupid method is to copy the library to C:\Program Files\Python3x\Lib\site-packages Then it can be executed normally .




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022156543519.html

Random recommended