我可以在 scp (Python版本2.7)中使用python脚本安装以下软件包。但是在 jenkins 中,我收到语法错误。
PYTHON CODE:
VIRT_DIR = "home/user/vitual_dir/"
subprocess.call("pip install --user virtualenv", shell=True)
subprocess.call("python -m virtualenv " + VIRT_DIR, shell=True)
activate_this = (VIRT_DIR + "/bin/activate_this.py")
execfile(activate_this, dict(__file__= activate_this))
subprocess.call("pip install pylint", shell=True)
subprocess.call("pip install coverage", shell=True)
subprocess.call("pip install pytest", shell=True)
jenkins中的错误消息:(python版本2.6.6)
Traceback (most recent call last):
File "/home/jenkins/vapor/bin/pip", line 7, in <module>
from pip._internal import main
File "/home/jenkins/vapor/lib/python2.6/site-
packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/home/jenkins/vapor/lib/python2.6/site-
packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/home/jenkins/vapor/lib/python2.6/site-packages/pip/_internal/index.py",
line 526
{str(c.version) for c in all_candidates},
^
SyntaxError: invalid syntax
请帮我解决这个问题。
答案 0 :(得分:0)
而不是
subprocess.call(&#34; python -m virtualenv&#34; + VIRT_DIR,shell = True)
我用过
subprocess.call(&#34; virtualenv&#34; + VIRT_DIR,shell = True)
现在,它工作正常。我可以安装python2.7