In Linux, if I execute this command in the terminal :
ipython '/media/folder1/myscript.py'
it works. But, If I execute in IPython terminal :
import subprocess
cmd_list= ["ipython", '/media/folder1/myscript.py' ]
proc= subprocess.Popen(cmd_list)
I have this error :
cmd_list= ["ipython", filescript]
proc= subprocess.Popen(cmd_list)
Traceback (most recent call last):
File "<ipython-input-47-66f9b0f2ed3f>", line 2, in <module>
proc= subprocess.Popen(cmd_list)
File "/home/linux1/anaconda2/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/home/linux1/anaconda2/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Why sub-process cannot execute this terminal command ?
Mike Müller
86.1k21 gold badges174 silver badges165 bronze badges
asked Dec 27, 2016 at 10:59
tensor
3,39010 gold badges43 silver badges73 bronze badges
-
1) If you multiprocessing, it will fails on pickle.... 2) What about if you want to launch 5 process in parallel...tensor– tensor2016年12月27日 13:14:46 +00:00Commented Dec 27, 2016 at 13:14
-
You use the dedicated multiprocessing module to properly execute the same bit of code as many times as you like. You'll only get pickle errors if you've designed your code incorrectlyAlastair McCormack– Alastair McCormack2016年12月27日 13:24:30 +00:00Commented Dec 27, 2016 at 13:24
-
Are you aware that some types are not easily serializable (nested classes).... Have you ever done distributed calculation ?tensor– tensor2016年12月28日 17:29:18 +00:00Commented Dec 28, 2016 at 17:29
-
In Python everything is an object so even the simplest user object will contain nested objects. Nested classes are nothing special. Both pickle just fine. I've done many multiprocessing projects which have shared data with other processes. Using Pickled objects isn't necessary for distributed calculation. How does forking in iPython give you distributed calculation? It sounds like you've made a number of assumptions. Perhaps you could explain your actual requirement in a new questionAlastair McCormack– Alastair McCormack2016年12月28日 18:05:47 +00:00Commented Dec 28, 2016 at 18:05
-
Thanks, Sure, I have this issue in pickling some classes : github.com/cloudpipe/cloudpickle/issues/74tensor– tensor2016年12月29日 06:50:39 +00:00Commented Dec 29, 2016 at 6:50
1 Answer 1
You need to specify the full path for ipython.
Type:
which ipython
in a terminal and use the path it tells you with subprocess:
cmd_list= ["/path/from/which/ipython", '/media/folder1/myscript.py']
Alternatively, you can try with shell=True:
subprocess.Popen(cmd_list, shell=True)
This might not be recommended, depending on your usage.
answered Dec 27, 2016 at 11:03
Mike Müller
86.1k21 gold badges174 silver badges165 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py