Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip: inconsistent permissions issues

When installing a package via sudo pip-python (CentOS 6 package: python-pip-0.8-1.el6.noarch), I sometimes get permission issues with the installed packages being readable only by root.

Re-installing again one or two times usually fixes the problem. Has anyone experienced this? Or can anyone suggest any troubleshooting steps to nail down the cause?

like image 558
Belmin Fernandez Avatar asked Jun 22 '12 18:06

Belmin Fernandez


People also ask

Why pip is not working in Python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.

Does pip install packages for all users?

¶ Passing the --user option to python -m pip install will install a package just for the current user, rather than for all users of the system.

Does pip install dependencies automatically?

Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI). But if packages are installed one at a time, it may lead to dependency conflicts.


1 Answers

When you run a command using sudo, it will preserve the users umask. pip just installs files, it doesn't change access rights, so you'll end up with the files having the access rights set conforming to the current user's umask, which may be owner-readable only (0077) and therefore readable by root only.

That means you can set umask to something sensible like umask 0022 before running sudo pip install. Or use sudo su to open a root shell with default settings and then pip install.

like image 114
mata Avatar answered Sep 25 '22 00:09

mata