我刚接触Python,并尝试使用Jenkinsfile自动化python构建,为此,我正在创建虚拟环境,然后安装 pybuilder 。但是 pybuilder 安装因权限问题而失败,
命令:
virtualenv venv
source venv/Scripts/activate
pip install pybuilder
pyb
输出:
+ pip install virtualenv
Collecting virtualenv
Downloading https://.../repository/pypi-public/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl (1.9MB)
Installing collected packages: virtualenv
Successfully installed virtualenv-16.0.0
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
+ virtualenv --version
16.0.0
+ virtualenv venv
Using base prefix 'f:\\app\\python'
New python executable in ...\venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.
+ source venv/Scripts/activate
++ deactivate nondestructive
++ unset -f pydoc
++ '[' -z '' ']'
++ '[' -z '' ']'
++ '[' -n /usr/bin/sh ']'
++ hash -r
++ '[' -z '' ']'
++ unset VIRTUAL_ENV
++ '[' '!' nondestructive = nondestructive ']'
+++ '[' msys == cygwin ']'
+++ echo .../py/venv
++ VIRTUAL_ENV=.../venv
++ export VIRTUAL_ENV
++ _OLD_VIRTUAL_PATH='...'
++ PATH='...'
++ export PATH
++ '[' -z '' ']'
++ '[' -z '' ']'
++ _OLD_VIRTUAL_PS1=
++ '[' x '!=' x ']'
+++ basename ...
++ PS1='(venv) '
++ export PS1
++ alias pydoc
++ '[' -n /usr/bin/sh ']'
++ hash -r
+ pip --version
pip 18.1 from ...\venv\lib\site-packages\pip (python 3.5)
+ pip install pybuilder
Looking in indexes: https://.../repository/pypi-public/simple
Collecting pybuilder
Downloading https://.../repository/pypi-public/packages/c0/23/57ef070a20ca2ff7852371056a57fef2d95d74b1b99e01bb7200dc7e80e5/pybuilder-0.11.17-py3-none-any.whl (114kB)
Collecting pip<11dev,>=7.1 (from pybuilder)
Downloading https://.../repository/pypi-public/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
Requirement already satisfied: tailer in g:\applications\jenkins\slaves\stcjs3\workspace\py\venv\lib\site-packages (from pybuilder) (0.4.1)
Requirement already satisfied: tblib in g:\applications\jenkins\slaves\stcjs3\workspace\py\venv\lib\site-packages (from pybuilder) (1.3.2)
Collecting setuptools~=39.0.0 (from pybuilder)
Downloading https://.../repository/pypi-public/packages/20/d7/04a0b689d3035143e2ff288f4b9ee4bf6ed80585cc121c90bfd85a1a8c2e/setuptools-39.0.1-py2.py3-none-any.whl (569kB)
Requirement already satisfied: wheel~=0.31 in ...\venv\lib\site-packages (from pybuilder) (0.32.1)
Installing collected packages: pip, setuptools, pybuilder
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: '...venv\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.
我在这里看到 pybuilder 下载了它自己的 pip 模块并尝试安装它。由于已经安装了 pip ,它正在尝试卸载当前版本并尝试安装下载的版本,但失败。
它失败是因为 pybuilder安装本身使用 pip 命令运行,并且pip试图杀死自己。
当我搜索此内容时,我知道它在Windows环境中是不可能的:https://github.com/pypa/pip/issues/3804
Python版本是3.5.4。
有人早些时候遇到过同样的问题吗?