launch external shell python instance in shell from python
Question: I'd like to call a separate non-child python program from a python script and
have it run externally in a new shell instance. The original python script
doesn't need to be aware of the instance it launches, it shouldn't block when
the launched process is running and shouldn't care if it dies. This is what I
have tried which returns no error but seems to do nothing...

    
    
    import subprocess
    
    python_path = '/usr/bin/python'
    
    args = [python_path, '&']
    
    p =  subprocess.Popen(args, shell=True)
    

What should I be doing differently

### EDIT

The reason for doing this is I have an application with a built in version of
python, I have written some python tools that should be run separately
alongside this application but there is no assurance that the user will have
python installed on their system outside the application with the builtin
version I'm using. Because of this I can get the python binary path from the
built in version programatically and I'd like to launch an external version of
the built in python. This eliminates the need for the user to install python
themselves. So in essence I need a simple way to call an external python
script using my current running version of python programatically.

I don't need to catch any output into the original program, in fact once
launched I'd like it to have nothing to do with the original program

### EDIT 2

So it seems that my original question was very unclear so here are more
details, I think I was trying to over simplify the question:

I'm running OSX but the code should also work on windows machines.

The main application that has a built in version of CPython is a compiled c++
application that ships with a python framework that it uses at runtime. You
can launch the embedded version of this version of python by doing this in a
Terminal window on OSX

    
    
    /my_main_app/Contents/Frameworks/Python.framework/Versions/2.7/bin/python
    

From my main application I'd like to be able to run a command in the version
of python embedded in the main app that launches an external copy of a python
script using the above python version just like I would if I did the following
command in a Terminal window. The new launched orphan process should have its
own Terminal window so the user can interact with it.

    
    
    /my_main_app/Contents/Frameworks/Python.framework/Versions/2.7/bin/python my_python_script
    

I would like the child python instance not to block the main application and
I'd like it to have its own terminal window so the user can interact with it.
The main application doesn't need to be aware of the child once its launched
in any way. The only reason I would do this is to automate launching an
external application using a Terminal for the user


Answer: If you're trying to launch a new terminal window to run a new Python in (which
isn't what your question asks for, but from a comment it sounds like it's what
you actually want):

You can't. At least not in a general-purpose, cross-platform way.

Python is just a command-line program that runs with whatever
stdin/stdout/stderr it's given. If those happen to be from a terminal, then
it's running in a terminal. It doesn't know anything about the terminal beyond
that.

If you need to do this for some specific platform and some specific terminal
program—e.g., Terminal.app on OS X, iTerm on OS X, the "DOS prompt" on
Windows, gnome-terminal on any X11 system, etc.—that's generally doable, but
the way to do it is by launching or scripting the terminal program and telling
it to open a new window and run Python in that window. And, needless to say,
they all have completely different ways of doing that.

And even then, it's not going to be possible in all cases. For example, if you
ssh in to a remote machine and run Python on that machine, there is no way it
can reach back to your machine and open a new terminal window.

On most platforms that have multiple possible terminals, you can write some
heuristic code that figures out which terminal you're currently running under
by just walking `os.getppid()` until you find something that looks like a
terminal you know how to deal with (and if you get to `init`/`launchd`/etc.
without finding one, then you weren't running in a terminal).

