0

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
6
  • 1) If you multiprocessing, it will fails on pickle.... 2) What about if you want to launch 5 process in parallel... Commented 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 incorrectly Commented Dec 27, 2016 at 13:24
  • Are you aware that some types are not easily serializable (nested classes).... Have you ever done distributed calculation ? Commented 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 question Commented Dec 28, 2016 at 18:05
  • Thanks, Sure, I have this issue in pickling some classes : github.com/cloudpipe/cloudpickle/issues/74 Commented Dec 29, 2016 at 6:50

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.