sudo pip3 install & wrong permissions

Adam Funk a24061 at ducksburg.com
Tue Jan 16 12:01:44 UTC 2018


On 2018-01-15, Colin Watson wrote:

> On Mon, Jan 15, 2018 at 03:51:12PM +0000, Adam Funk wrote:
>> When I install Python packages with `sudo -H pip3 install -U
>> [packages]`, the files end up readable & executable by root only, so I
>> have to do `sudo chmod -Rc a+rX /usr/local/lib/python*` afterwards to
>> make them usable.
>> 
>> What exactly do I need to set to fix this, without compromising normal
>> security?
>
> If you need to use pip rather than relying on system packages, then I'd
> strongly recommend doing so in conjunction with virtualenv.  That way
> you don't have to drop things into /usr/local, and if you find that some
> other thing you want to run needs a conflicting set of Python packages
> (after all, you've had to do this job once, so why not a second time?)
> then they can have environments that don't interfere with each other.

I think this is probably a smart idea.  I've recently started using
virtualenv (combined with screen over ssh) on a server at work, but
I've been running experiments in the same screen session for a while
so I haven't had to re-enable it.

Is it possible to set virtualenv up so that when I open an xterm it
will have everything set up so my scripts will run right away?  Is it
possible to set it up so scripts running in cron & at jobs have access
to the libraries in the virtualenv?

Thanks,
Adam





More information about the ubuntu-users mailing list