pip3 : command not found

Steve D'Aprano steve+python at pearwood.info
Sat Nov 5 12:53:20 EDT 2016


On Sun, 6 Nov 2016 02:55 am, Jon Ribbens wrote:

> I'm afraid I can only suggest that you try re-reading the subthread
> again until you manage to understand it. It wasn't really that
> complicated but you seem to have confused yourself greatly.

Are you serious?

Okay. Here's the start of the thread:

https://mail.python.org/pipermail/python-list/2016-October/715993.html

where the OP asks for help because running "pip3" causes a "command not
found" error. Just as the subject line says.

Here's Ben's reply:

https://mail.python.org/pipermail/python-list/2016-October/715994.html

where he clearly says not to rely on the "pip3" command, as it may not
exist, or may not be in the environment you expect, but to specify
precisely which Python interpreter you want to run:

    [quote]
    Instead, you should invoke the exact Python interpreter you want


And here's your response:

https://mail.python.org/pipermail/python-list/2016-October/716005.html

where you quote those exact same words from Ben and ask what difference it
makes as it is a symbolic link. You'll note that there is not one word
about "activate" in your post, just as I said. Instead you question why Ben
thinks there's a difference between running the sym link and running the
direct link to the executable, even though that's not what Ben said.

I can only repeat yet again: you have not understood Ben. He's not stating
that there is a difference between:

    /direct/path/to/python3.x

and 

    /symbolic/link/to/direct/path/to/python3.x


You are right to state that they will be exactly the same[1], but wrong to
imagine that Ben said that they were different. That's not what Ben said.
He stated that there is a difference between:

    /direct/path/to/python3.x -m pip ...

which specifies the precise Python environment you want to run, and:

    pip3 ... 

which may not exist at all, or if it exists it may not be on the PATH, or if
it is on the PATH it may not install into the Python environment that you
expect.


Oh, and ironically, you'll see that Ben anticipated and answered your
question about activate. Here's the link again, to save you scrolling up:

https://mail.python.org/pipermail/python-list/2016-October/715994.html

where he says:

    If you already have a specific environment active and know that
    ‘python3’ is the correct Python interpreter from that environment,
    you can omit the explicit path.


The implication is that the answer to your question is Yes, you can run
Python in the context of a virtualenv by just invoking that virtualenv's
local Python without running 'activate' first. Is Ben correct? The
virtualenv documentation confirms that Ben is right:

    If you directly run a script or the python interpreter from the
    virtualenv’s bin/ directory (e.g. path/to/ENV/bin/pip or 
    /path/to/ENV/bin/python-script.py) there’s no need for activation.

https://virtualenv.pypa.io/en/stable/userguide/#activate-script






[1] Technically, the application being run may invoke different behaviour
depending on the name it was invoked by. Some editors do that, e.g.
the "joe" editor. But I don't believe Python does anything like this.

http://joe-editor.sourceforge.net/

-- 
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