我有一个jenkins工作,我使用virtualenv,然后安装一些python模块(登记在一个需求文件中)。
我的代码非常简单:
virtualenv env
source ./env/bin/activate
echo $(python --version)
echo $(which pip)
echo $(pip --version)
当我的作业运行时,哪个python和哪个pip显示正确的输出但是pip --version会引发错误:
++ which python
/scratch/jenkins/ncs-jenkins/workspace/proj/docker/mail/tools/ici/gate/kokilla-gold/testproj-my deploy-newchanges-20/env/bin/python
++ which pip
/scratch/jenkins/ncs-jenkins/workspace/proj/docker/mail/tools/ici/gate/kokilla-gold/testproj-my deploy-newchanges-20/env/bin/pip
++ pip --version
/tmp/hudson2230168319717284464.sh: /scratch/jenkins/ncs-jenkins/workspace/proj/docker/mail/tools/ici/gate/kokilla-gold/testproj-my deploy-newchanges-20/env/bin/pip: /scratch/jenkins/ncs-jenkins/workspace/proj/docker/mail/tools/ici/gate/kokilla-gold/testproj-my deploy-newchanges-20/: bad interpreter: No such file or directory
我认为这里发生的事情是,shebang线大于127个字符,导致问题。它还引用了here。我的路径是
PATH=/scratch/jenkins/ncs-jenkins/workspace/proj/docker/mail/tools/ici/gate/kokilla-gold/testproj-my deploy-newchanges-20/env/bin:/usr/local/bin:/usr/bin
/ scratch / jenkins / ncs-jenkins / workspace / proj / docker / mail / tools / ici / gate / kokilla-gold / testproj-mydeploy-newchanges-20 / env / bin / pip是一个文本文件。以下是其内容:
#!/scratch/jenkins/ncs-jenkins/workspace/proj/docker/mail/tools/ici/gate/kokilla-gold/testproj-mydeploy-newchanges-20/env/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
我不知道如何更改pip中的shebang行,因为当我运行virtualenv时,它会自动生成并存储在我的Jenkins工作区中。我该怎么做才能防止此错误?