My first real request for help

Peter Otten __peter__ at web.de
Tue Nov 19 12:46:54 EST 2013


Gene Heskett wrote:

> On Tuesday 19 November 2013 11:16:10 Peter Otten did opine:
> 
>> Gene Heskett wrote:
>> > Old python, 2.6.4 I believe, not update able from the Ubuntu 10.04.3
>> > LTS repo's.
>> > 
>> > Should be a mauchs nichs as the code was written on, and is running
>> > on, several of these same linuxcnc installs.
>> > 
>> > But when I switch in, as one of the plugins a new .py version of
>> > camview- emc, I get this when I attempt to run linuxcnc -l, where the
>> > -l is "use the same config as last time" option.
>> > 
>> > Starting LinuxCNC...
>> > 
>> > Traceback (most recent call last):
>> >   File "/usr/bin/axis", line 3326, in <module>
>> >   
>> >     _dynamic_tabs(inifile)
>> >   
>> >   File "/usr/bin/axis", line 3182, in _dynamic_tabs
>> >   
>> >     child = Popen(cmd)
>> >   
>> >   File "/usr/lib/python2.6/subprocess.py", line 633, in __init__
>> >   
>> >     errread, errwrite)
>> >   
>> >   File "/usr/lib/python2.6/subprocess.py", line 1139, in
>> >   _execute_child
>> >   
>> >     raise child_exception
>> > 
>> > OSError: [Errno 2] No such file or directory
>> > 
>> > No clue, even when straced, as to what file might be missing.
>> > 
>> > So, how do I find out?
>> 
>> How about inserting a
>> 
>> print cmd
>> 
>> before the line
>> 
>> child = Popen(cmd)
>> 
>> ? Depending on its value it may not even be a missing command, e. g.
>> This doesn't work:
>> 
>> Python 2.6.7 (r267:88850, Sep 28 2012, 16:26:39)
>> [GCC 4.6.1] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> 
>> >>> import subprocess
>> >>> subprocess.Popen("ls -1")
>> 
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
>>     errread, errwrite)
>>   File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
>>     raise child_exception
>> OSError: [Errno 2] No such file or directory
>> 
>> But this works:
>> >>> subprocess.Popen(["ls", "-1"])
>> 
>> <subprocess.Popen object at 0x7f8b31c5cfd0>
>> 
>> >>> alpha
>> 
>> beta
>> gamma
>> 
>> And this works, too (but is a bit less robust):
>> 
>> subprocess.Popen("ls -1", shell=True)
>> <subprocess.Popen object at 0x7f8b31c5cd90>
>> 
>> >>> alpha
>> 
>> beta
>> gamma
> 
> You are suggesting I edit /usr/lib/python2.6/subprocess.py?

No, first and foremost I suggested that you find out the actual value of 
cmd.

Only if that's indeed

(a) a string and
(b) contains a command with options

my demo shows two possible fixes that you can apply to the Popen() call in 
the _dynamic_tabs() function:

(1) The clean one: Make sure that cmd is a list with the executable as the 
first item and the options as the following items (this will require changes 
in other places), or

(2) The quick and dirty one: Leave everything as is and add shell=True to 
the Popen() call.





More information about the Python-list mailing list