Installing python3 packages using pip

Chris Angelico rosuav at gmail.com
Thu Aug 8 15:04:31 EDT 2019


On Fri, Aug 9, 2019 at 5:01 AM Rich Shepard <rshepard at appl-ecosys.com> wrote:
>
> On Fri, 9 Aug 2019, Chris Angelico wrote:
>
> > Once you're using pip3, you don't need to specify the 3 anywhere else. It
> > should just be "pip3 install numpy". The pip download resolver will make
> > sure that it gets a version that's appropriate to your Python (including
> > architecture/word size, version (x.y), etc, etc).
>
> ChrisA,
>
> Well! This is the first I've learned of the proper way to install python3
> packages from PyPI. Thank you.
>
> Numpy, scipy, and matplotlib all installed properly.
>

Awesome!

There's one other potential trap you MAY fall into, but only if you
have multiple Python 3s installed (eg 3.7, 3.8, and 3.9). The name
"pip3" may or may not correspond to the actual Python installation
that you want to target. So to be absolutely completely safe, you can
write it like this:

python3 -m pip install numpy

If you replace "python3" with "python3.7" or something, it'll still
work, and whatever you use, it'll target the same Python that you'd
get when you run a script (so "python3.7 scriptname.py" will see
things installed with "python3.7 -m pip install pkg").

Not something to worry about right now, but if you run into trouble,
this is the longhand that "pip3" is the shorthand for.

ChrisA



More information about the Python-list mailing list