[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] How can I add a path to the QProcess PATH environment variable?
From:       J Barchan <jnbarchan () gmail ! com>
Date:       2018-11-23 15:56:23
Message-ID: CABz3M__yxjUsb0KFae0tgT+5hjv1zO9AGivdcpa5MkvZdjCRLA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

> 
> 
> On November 23, 2018 10:38:33 AM EST, J Barchan <jnbarchan@gmail.com>
> wrote:
> > On Fri, 23 Nov 2018 at 15:27, Kyle Altendorf <sda@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@gmail.com>
> > > wrote:
> > > > On Fri, 23 Nov 2018 at 09:04, <kristof.mulier@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@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


[Attachment #5 (text/html)]

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



[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic