无法在jenkins中使用pip

时间:2017-06-19 11:32:16

标签: python jenkins pip virtualenv

我正在尝试在jenkins作业中创建virtualenv,然后安装requirements.txt。但我无法创建virtualenv。这就是我的Jenkins文件的样子。

sh 'sudo easy_install pip; pip install virtualenv'

但我得到了

+ sudo easy_install pip
Searching for pip
Best match: pip 9.0.1
Processing pip-9.0.1-py2.7.egg
pip 9.0.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
+ pip install virtualenv
/Users/Shared/Jenkins/Home/workspace/test-jenkinsfile@tmp/durable-e0a93859/script.sh: line 3: pip: command not found

1 个答案:

答案 0 :(得分:5)

在用户的路径中找不到pip命令。解决方案是直接从/ usr / local / bin / pip调用它,或者将/ usr / local / bin添加到用户的路径

for bash:PATH=${PATH}:/usr/local/bin

for(t)csh:setenv PATH "${PATH}:/usr/local/bin"