How to install a module for all users with pip on linux?
You might have a wrong
umask set as discussed here
From your last edit, I guess you
umask is set to
027. Try to do
sudo pip uninstall loremipsum
sudo pip install loremipsum
Pip3 Install Module For All Users
I suspect that your startup scripts are launching a different Python than the one you have installed discord to.
Try adding the line,
import sys; print(sys.executable, sys.prefix)
main.py, before the
import discord. And also try running that in your
python3 shell. This should print off where the Python executable and standard library are installed, respectively. If they're different in
main.py than in the shell, that's your issue.
$ which python3
$ which pip3
Once you know the path to the Python executable you're actually running, you can use that Python's pip with
$ foo -m pip install discord
foo is the full path to the Python executable you printed off with
sys.executable in your
You can also try installing
discord to a virtual environment.
$ python3 -m venv foo
$ source foo/bin/activate
$ pip install discord # install all your other requirements too
foo is some path you can install the virtual environment to. Then in your launch script, do the source activate before running
main.py. This ensures that python will run in the same
foo environment you just created.
Note that in an active virtual environment, you use
pip even if you created the environment with
Install a python package for all users without messing with the system python installation
No, you can never be too afraid of modifying the system Python. Your caution is justified.
I’d suggest you let all users share a global (but non-system) Python installation, either from the official distribution, Anaconda, pyenv’s python-build, or self-compiled source. Each user can then either perform their own
pip install --user to their respective home directories, or you can, as an sudoer, install tools globally available to them, into the custom-managed, non-system, but global Python.
Edit: I forgot to mention that you may also do this with virtual environments and symlinks. An example for Pipenv (you can change paths as you prefer):
python3 -m venv /opt/venvs/pipenv
/opt/venvs/pipenv/bin/pip install pipenv
ln -s /opt/venvs/pipenv/bin/pipenv /opt/bin/pipenv
python3 -m venv /opt/venvs/flake8
/opt/venvs/pipenv/bin/pip install flake8
ln -s /opt/venvs/pipenv/bin/flake8 /opt/bin/flake8
This way to can install multiple tools without them affecting each other. Also you can combine this with custom-managed Python for even more peace of mind.
Can I use pip install to install a module for another users?
sudo should install a package for all users
sudo pip install numpy
If it doesn't work, try
sudo -H -u www-data pip install --user numpy
which should install numpy only for
Make Python module available for all Linux users
Ok, I solved the issue.
In my case, the problematic module was "faker". But, when we install the faker, another additional module is installed as well (in this case - text-unidecode).
Then I uninstalled both modules, ran "umask 022" and re-installed the faker.
This solved the issue for all other users.
Thanks all for the help!
What is the purpose of "pip install --user ..."?
pip defaults to installing Python packages to a system directory (such as
/usr/local/lib/python3.4). This requires root access.
--user makes pip install packages in your home directory instead, which doesn't require any special privileges.