Using sudo with pip3?

Clint Moyer contact at clintmoyer.com
Fri Jan 6 18:03:05 EST 2017


Packages supplied by your distribution can be trusted more than packages
from PyPi. Just my two cents.

Most distros offer nearly all the useful Python modules directly from the
repo.

Virtual environments are great, but if you want to add libraries to your
system interpreter I'd recommend a simple sync through your repo.

- Clint

On Fri, Jan 6, 2017 at 3:38 PM <cs at zip.com.au> wrote:

> On 06Jan2017 15:44, jim <jf_byrnes at comcast.net> wrote:
>
> >Setting up a new computer to run Ubuntu 16.04. Started using pip3 to
>
> >install all the python stuff I had on the old machine and got this
>
> >message:
>
> >
>
> >jfb at jims-1604:~$ sudo pip3 install matplotlib
>
> >[sudo] password for jfb:
>
> >The directory '/home/jfb/.cache/pip/http' or its parent directory is
>
> >not owned by the current user and the cache has been disabled. Please
>
> >check the permissions and owner of that directory. If executing pip
>
> >with sudo, you may want sudo's -H flag.
>
> >
>
> >I (jfb) own the directory in question.
>
> >
>
> >I used sudo because I recall needing to use it on the old machine to
>
> >get something to install. So is it necessary or even desirable to use sudo
>
> >with pip3?
>
>
>
> I would not, unless I were specificly trying to install into the system's
>
> python3 libraries. That will inherently fight with any vendor (Unbuntu)
>
> supplied packages that come through apt-get.
>
>
>
> Instead I would make myself a virtualenv _based off the system python3_
> and use
>
> the venv's pip to install extra packages. Not using sudo. They will land in
>
> your virtualenv directory's lib area, be entirely owned and controlled by
> you,
>
> and not have any complications that come with sudo.
>
>
>
> Then just symlink the virtualenv's "python3" into your own $HOME/bin and
>
> whenever you invoke "python3" it will run the virtualenv one, getting all
> the
>
> package goodness you have added.
>
>
>
> An important sysadmin rule of thumb: use apt (or yum etc, depending on
> distro)
>
> as root to install vendor supplied packages. And install your owon
> packages _as
>
> you_ in another area, _not_ in the system managed area. Virtualenv makes
> this
>
> very easy to do for Python.
>
>
>
> Cheers,
>
> Cameron Simpson <cs at zip.com.au>
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
>



More information about the Python-list mailing list