venv and executing other python programs

Barry Scott barry at barrys-emacs.org
Tue Feb 15 02:53:50 EST 2022



> On 15 Feb 2022, at 05:35, Mirko via Python-list <python-list at python.org> wrote:
> 
> Hi,
> 
> I have recently started using venv for my hobby-programming. There
> is an annoying problem. Since venv modifies $PATH, python programs
> that use the "#!/usr/bin/env python" variant of the hashbang often
> fail since their additional modules aren't install inside in venv.

Do you mean that your python code is running another python program
via subprocess?

You would need to provide a PATH that does not include the venv so that env
works as expected.

Or are you running the program from the command line after activating the
venv?

I create the venv and use it to run the program using
 <path-to-venv>/bin/python program.py without activating the venv

> How to people here deal with that?
> 
> Please note: I'm not interested in discussing whether the
> env-variant is good or bad. ;-) It's not that *I* use it, but
> several progs in /usr/bin/.

At least for Fedora it does not allow packages to install programs
that use /usr/bin/env because of issues like you are seeing.

Barry

> 
> Thanks for your time.
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list