I have just updated a package using python-pip. Two different users get different versions of the binary:

andrew$ which aws

andrew$ /usr/bin/aws  --version
aws-cli/1.16.194 Python/3.5.2 Linux/4.4.0-1087-aws botocore/1.12.184

andrew$ sudo su tomcat

tomcat$ which aws

tomcat$ /usr/bin/aws --version
aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-1087-aws botocore/1.4.70

That's happening within an application running as the tomcat user, as well as from the commandline. I have upgraded from 1.11 to 1.16 today (using pip3 install --upgrade pip awscli), but the tomcat users still gets the old version. I've restarted the apache-tomcat server, logged out and in (although I haven't restarted the server). Is it even possible for a program to be cached by linux for one user but not another?

Based on the comments, I believe that the two users have different environments which mean that when python imports awscli.clidriver it's a different version. But how to find that out / fix it globally? debian stretch/sid, x86_64

  • 1
    What was the command use for updating? – muru Jul 9 '19 at 5:12
  • 2
    Are you sure /usr/bin/aws is a binary at all? I suppose it's a python script and the user's environment may have a different path setting, so a different aws-cli is imported. What does set |grep -i python return for both users? – Philippos Jul 9 '19 at 9:00
  • 1
    What's different in the environment? – mattdm Jul 10 '19 at 0:45
  • 1
    What was the command that was used to upgrade the module? – Nasir Riley Jul 10 '19 at 1:21
  • 1
    Most probably either different python installations or the difference in sys.path. Start with running ` python -c "import awscli; print('version:', awscli.__version__, 'root:', awscli.__file__)"` and sudo -u tomcat python -c "import awscli; print('version:', awscli.__version__, 'root:', awscli.__file__)" and inspecting the difference in paths. – hoefling Jul 12 '19 at 20:26

This was a pip environment problem. I don't really understand it because I'm sure the steps that solved it didn't work the first couple of times I tried them... But doing sudo apt-get remove awscli then pip3 uninstall awscli as both users then sudo pip3 install awscli finally installed it as I hoped.

After reading dozens of pip questions and answers all I know is that I don't understand how the various versions of pip interact with --user and sudo permissions. I'm not going to mark my own answer as correct, but happy to consider any other answers.

  • 1
    Using sudo for pip would overwrite system package provided files, do that only when you know what you're doing – 炸鱼薯条德里克 Jul 18 '19 at 7:49
  • Thanks 炸鱼薯条德里克 - that's why i'm not accepting my own answer! I don't really know what I'm doing, I only know that apt and pip --user both didn't do what i needed. – andrew lorien Jul 19 '19 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.