[PyQt] How can I add a path to the QProcess PATH environment variable?

J Barchan jnbarchan at gmail.com
Fri Nov 23 15:56:23 GMT 2018


On Fri, 23 Nov 2018 at 15:44, Kyle Altendorf <sda at fstab.net> wrote:

>
>
> On November 23, 2018 10:38:33 AM EST, J Barchan <jnbarchan at gmail.com>
> wrote:
> >On Fri, 23 Nov 2018 at 15:27, Kyle Altendorf <sda at fstab.net> wrote:
> >
> >> Why not just specify the full path to execute?  Setting PATH is for
> >> configuring other processes and being 'lazy' in a shell (reasonable
> >lazy,
> >> not bad lazy).
> >>
> >> Cheers,
> >> -kyle
> >>
> >> On November 23, 2018 4:14:42 AM EST, J Barchan <jnbarchan at gmail.com>
> >> wrote:
> >> >On Fri, 23 Nov 2018 at 09:04, <kristof.mulier at telenet.be> wrote:
> >> >
> >> >> Dear PyQt developers/users,
> >> >>
> >> >> I'm using a QProcess()-instance to execute commands. The
> >> >QProcess()-instance
> >> >> automatically inherits the standard environment, for example the
> >PATH
> >> >> environment variable. So if the command is an executable, it can
> >only
> >> >find
> >> >> it if it's in the PATH variable.
> >> >> Once the  QProcess()-instance exists, I just can't add anything to
> >> >its
> >> >> PATH variable. Well, actually I can, but it doesn't have any
> >effect.
> >> >I've
> >> >> explained everything in great details on StackOverflow:
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >
> https://stackoverflow.com/questions/53438065/how-can-i-add-a-path-to-the-qprocess-path-environment-variable-pyqt5-on-python
> >> >>
> >> >> I would be very thankful if you can have a look at it :-)
> >> >>
> >> >> Kind greetings,
> >> >>
> >> >> Kristof Mulier
> >> >> _______________________________________________
> >> >> PyQt mailing list    PyQt at riverbankcomputing.com
> >> >> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
> >> >
> >> >
> >> >I have posted a comment at *SO*:
> >> >
> >> >> I think you're misunderstanding. You are trying to affect the PATH
> >> >> environment which gets passed to the sub-process. What you *want*
> >to
> >> >do
> >> >> is simply alter the PATH environment in the *parent*, it is that
> >> >which
> >> >> needs to find your executable before the sub-process can get
> >spawned.
> >> >And
> >> >> if you want to, then change your parent's PATH back *after* the
> >> >> sub-process has been spawned
> >> >>
> >>
> >
> >@Kyle
> >I would have suggested that!  But the way I took the OP's full question
> >in
> >*SO* was "it *might* be on the PATH already, I don't know, so I just
> >want
> >to add something to the PATH to be sure just for this one-time spawn,
> >and
> >then let the OS find it somewhere for sure.  And, I don't fancy doing
> >the
> >PATH search myself from code". :)
>
> If they know it's available in the new location and they put that first in
> the PATH, it's not going to look anywhere else.  But sure, maybe there's
> more nuance somehow.
>
> Also, why the \r\n?
>

@Kyle, @kristof
Have put a couple of further comments into the *SO* thread to bring Kyle's
comments to OP's attention.


-- 
Kindest,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20181123/c4eb37ee/attachment-0001.html>


More information about the PyQt mailing list