pip3 : command not found

Michael Torrie torriem at gmail.com
Sun Nov 6 09:35:19 EST 2016


On 11/05/2016 11:27 PM, Jon Ribbens wrote:
>> 2) If Python notices that its executable comes from a venv, it uses it.
> 
> Yes. My question is *how does it notice*?

I'm guessing that it notices by examining the path it was launched from
and looks for virtual environment files relative to that path.

Here's what a random site said about this (I didn't search long enough
to find the official documentation on python.org):

"When Python is starting up, it looks at the path of its binary (which,
in a virtual environment, is actually just a copy of, or symlink to,
your system’s Python binary). It then sets the location of sys.prefix
and sys.exec_prefix based on this location, omitting the “bin” portion
of the path."

This is actually a common idiom in the unix world.  For example, busybox
works on this principle. You link the busybox executable and call it,
say, "cat" and when involved, busybox looks to see how what path it was
launched via and then behaves accordingly.




More information about the Python-list mailing list