pip3 : command not found

Steve D'Aprano steve+python at pearwood.info
Sat Nov 5 07:23:24 EDT 2016


On Sat, 5 Nov 2016 08:45 pm, Jon Ribbens wrote:

> On 2016-10-31, Steve D'Aprano <steve+python at pearwood.info> wrote:
>> On Mon, 31 Oct 2016 07:21 pm, Jon Ribbens wrote:
>>> On 2016-10-31, Ben Finney <ben+python at benfinney.id.au> wrote:
>>>> Instead, you should invoke the exact Python interpreter you want – and,
>>>> by extension, the Python environment into which you want packages
>>>> installed.
>>>>
>>>>     $ /foo/bar/virtualenv/bin/python3 -m pip install LoremIpsum
>>> 
>>> I'm slightly curious about that. /foo/bar/virtualenv/bin/python3
>>> will just be a symbolic link to /usr/bin/python3, so how does
>>> invoking the intepreter that way make any difference?
>>
>> It doesn't. If you read the rest of Ben's post, or for that matter the
>> subject line of this thread, you will see he is comparing:
>>
>>     path/to/python3 -m pip install LoremIpsum
>>
>> against:
>>
>>     pip3 install LoremIpsum
> 
> No, if you read the rest of Ben's post you will see that that is not
> what he wrote. 

Excuse me, that is what he wrote. As you yourself quoted.

The OP said he tried to call the "pip3" command, and got an error that the
command was not found. Ben replied:

"There is no guarantee that a command named ‘pip3’ will be installed."

and then stated:

"Instead, you should invoke the exact Python interpreter you want"

The fact that (and now I'm quoting *you*, not Ben) 

    /foo/bar/virtualenv/bin/python3 will just be a symbolic link
    to /usr/bin/python3

is irrelevant. It doesn't matter whether you call python3 via the actual
executable file, or the symbolic link. But Ben never suggested that it
would make a difference: he was contrasting calling the actual Python
interpreter wanted (Python 3, via a virtualenv) with calling a command pip3
(which does not actually exist on the OP's system).


Your implied question here:

> Maybe he meant what you are saying, I don't know, but 
> it isn't what he wrote. He clearly implied that you can run Python
> in the context of a virtualenv by just invoking that virtualenv's
> local Python without running 'activate' first. I'm curious as to
> whether this is true or not (how virtualenvs work seems to be very
> opaque).

is a separate issue from the symbolic link question. Possibly you do have to
run `activate` first, I don't know, but either way this was not part of
your earlier question. You said nothing about `activate` in your earlier
post, and this is the first time you have mentioned it.

The bottom line is, I couldn't have answered your question about `activate`
because you hadn't asked it yet; you are correct that there's no difference
between calling Python via the executable and via a symlink; but Ben never
said that there was such a difference.


This thread reminds me of a scene from the Marx Bros movie "At The Circus".
Alas, Google has let me down as far as the exact quote, but it goes
something like this:

Groucho Marx, accidentally letting the big secret slip: 
    "The elephants will be here soon."

Society dame Margaret Dumont, taken aback:
    "Elephants? What elephants?"

Groucho:
    "Nobody said anything about elephants!"

    [shakes head disgustedly]

    "Elephants! At your age!"


I'll let you decide whether I'm Groucho or Dumont.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list