Using sudo with pip3?
contact at clintmoyer.com
Sat Jan 7 13:39:40 EST 2017
All Linux operating systems come with Python installed, with more
recent systems such as Arch defaulting /usr/bin/python to Python3,
since Python2 discontinued some 7-9 years ago. I believe Ubuntu still
defaults that to Python2, however.
So when you run pip3 you are attempting to download and install a
package from the internet, specifically the PyPi repository. You are
deliberately avoiding your Package Repository from your OS in this
scenario. That's fine, but when the package requires root privilege to
install arbitrary executables and bindings in the root filesystem, you
are taking on too much risk to be acceptable.
Which is why nearly all current Linux OS systems have these common
Python packages ready for instant download, through the respective
I find the benefit of adding libraries directly to your system's
Python, outweighs the extra effort of setting up a VirtualEnv. When it
comes to individual projects, that's when I'll set up the env. Being
able to run those commands directly:
$ ansible-playbook run.yml
Is quite useful. Working in the field, sadly the most common
roadblocks I see are difficulties installing through Pip, or even a
VirtualEnv. Much better off going through your system, and learning
what other dependencies may be needed.
On Sat, Jan 7, 2017 at 11:22 AM, jim <jf_byrnes at comcast.net> wrote:
> On 01/06/2017 08:24 PM, Cameron Simpson wrote:
>> On 06Jan2017 23:03, Clint Moyer <contact at clintmoyer.com> wrote:
> Thanks everyone for the advice. Please note in my following comments I am
> not arguing with anyone, merely trying to understand. I am not a
> professional programmer, just someone who enjoys programing for my own
> use/enjoyment and I am the only user of this system.
>>> 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
>> I would agree with this on the whole. And also that it is generally
>> better to add modules to your system python via the distro's repo
>> because that bring benefit to every user on the system, not just yourself.
> What is "system python"? If I do $ which python I get /usr/bin/python which
> points to python 2.7xx. So if everything I added was for python 3 either
> using pip3 or apt-get would I be adding to "system python"?
> I see that most of the "major" python3 modules I had installed, with the
> exception of scripy, are in the repository. If I upgraded one of the
> repository modules using pip3 would I lose the benefits of installing from
> the repository? I know it seems to be possible as I installed pip3 from the
> repository. The first time I used it to install a module it informed me
> there was a more current version available and showed me the command to
> update. I updated and it seems to be fine.
>>> Virtual environments are great, but if you want to add libraries to your
>>> system interpreter I'd recommend a simple sync through your repo.
>> I'm directly advocating _not_ adding PyPI packages to the system
>> interpreter. If nothing else, they may differ in behaviour and
>> potentially actually break system behaviour.
>> Having your on virtualenv is good for: adding packages no provided by
>> your vendor, adding packages deliberately different from those from your
>> vendor (eg newer versions with specific bugfixes or extra features),
>> having an isolated environment for packages (you can make more than one
>> virtual environment).
>> And of course it avoids interfering with your system python install.
> A number of years ago I had virtualenv installed. At the time I remember it
> took me a while to get it installed and working. Right now I am working on
> some scripts to download some financial date using Selenium and paste it
> into Libreoffice Calc spreadsheets. Will using virtualenv have any effect
> on me running those scripts?
> Thanks, Jim
>> Cameron Simpson <cs at zip.com.au>
More information about the Python-list