Search code examples
pythonpipvirtualenvpybuilder

windows: pip uninstallation fails with access denied


I am new to Python and trying to automate python build with Jenkinsfile, For that I am creating virtual environment and then installing pybuilder. But pybuilder installations fails with permission issues,

commands:

    virtualenv venv
    source venv/Scripts/activate        
    pip install pybuilder       
    pyb

Output:

+ 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.

Here what I see pybuilder downloads it's own pip module and tries to install it. As pip is already installed, it is trying to uninstall current version and tries installing downloaded version and it fails.

It fails because pybuilder install itself running with pip command and pip try killing itself.

When I searched about this, I got to know its not possible in windows environment: https://github.com/pypa/pip/issues/3804

Python version is 3.5.4.

Anyone faced same issues earlier ?


Solution

  • Try using python executable (run this from an admin command line).

    python -m pip install pybuilder
    

    More on that on this answer.