Pip installs to unexpected place

Thomas Passin list1 at tompassin.net
Mon Apr 14 23:11:58 EDT 2025


On 4/14/2025 6:20 PM, Keith Thompson via Python-list wrote:
> Thomas Passin <list1 at tompassin.net> writes:
> [...]
>> To activate a venv, you have to source its activate script, which is
>> in the venv. First you have to mark it as executable.  Then you source
>> it -
>>
>> source ~/venv/gf4/bin/activate
> [...]
> 
> No, you don't have to (and probably shouldn't) mark the script as
> executable.
> 
> Making a script executable (chmod +x) is required before *executing* it,
> but when you *source* a script (using "source" or "."), your current
> shell reads it and evaluates its content.
> 
> Making the active script executable introdues the risk that you'll
> accidentally execute it rather than sourcing it.  If you do that, it
> will probably set up the environment in a new shell process which then
> immediately terminates.

You are right, my bad.  When I went to check on what the venv prompt 
looked like after activation, I hadn't run my Linux VM for too long and 
forgot that the activate script needs to be sourced - in Windows it just 
gets run as any other script. I noticed it wasn't marked executable and 
blindly "fixed" that.  Then of course I remembered the script has to be 
sourced  - and forgot to undo the execute flag.



More information about the Python-list mailing list