Can pip install packages for all users (on a Linux system)?

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Tue Jul 24 15:36:52 EDT 2018


On 24.07.2018 20:07, John Ladasky wrote:
> I've been using "sudo pip3 install" to add packages from the PyPI repository.  I have multiple user accounts on the computer in question.  My goal is to install packages that are accessible to all user accounts.  I know that using the Synaptic Package Manager in Ubuntu will install for all users, but not every Python package is included in the Canonical repository.
> 
> I hadn't noticed any discrepancies until recently.  I upgraded from Ubuntu 17.10 to 18.04.  In parallel, I upgraded tensorflow-gpu 1.4.0 to 1.8.0.  Everything worked on my main account.  However, attempting to import tensorflow from Python on a secondary account failed.  Eventually I checked the pip lists in each account, and I found a reference to the old tensorflow 1.4 on the secondary account.  Uninstalling that, and reinstalling tensorflow-gpu 1.8 on the secondary account fixed the problem.
>

One possible explanation for your finding: user installs normally take 
precedence over system-wide installs both at import time and for pip 
(list, uninstall, etc.). So if you, or your users, have installed 
tensorflow 1.4.0 using pip install --user before, then a system-wide pip 
install tensorflow 1.8.0 won't override this previous version (though if 
your admin account has the user install, too, pip would warn you).
Otherwise, a pip install without --user is effectively a system-wide 
install as long as your Python is a system-wide install.

> I believe that I now have tensorflow 1.8 installed twice on my system, once for each user.  If anyone can share how to convince pip to behave like Synaptic, I would appreciate it.  Thanks.
> 

If a user has a user install of tensorflow, it will always shadow the 
system-wide version. The only solution I know (except manipulating 
Python's import path list) is to pip uninstall the per-user version.

Best,
Wolfgang



More information about the Python-list mailing list