Subprocess Popen fails to execute if python exits straight after - subprocess

The following code fails to launch my application on Python 3.7 on Mac 10.15.3.
import subprocess
cmdLine = "/Applications/RV.app/Contents/MacOS/RV"
subprocess.Popen(cmdLine, shell=True)
It doesn't throw an error, it just doesn't do anything.
If I run the same code in Python 2.7 it works correctly and launches the application, without waiting for it.
I discovered by debugging and walking through the subprocess code that it actually launched when I did that. Which lead me to try:
import subprocess
import time
cmdLine = "/Applications/RV.app/Contents/MacOS/RV"
subprocess.Popen(cmdLine, shell=True)
time.sleep(1)
Which then worked. It seems that the Popen command is not managing to spawn the separate process before python exits. Am I doing something wrong here?
Edit:
It appears like it also has something to do with the actual application I'm trying to launch. Launching the Calculator app or Firefox, for example, does work without the added sleep.

Related

Debugging Deno code in either vscode or rider won't terminate debugger when program ends

I'm able to debug Deno code in both VSCode and Rider, however, the debugger continues running even after the program terminates. I tested with a single line program, console.log('hello'), and it still had the problem. When it ends, you have to remember to stop the debugger.
Is this a bug?

Importing Pandas Terminates Eclipse PyDev Debugger when I add PyInstaller

I'm getting an odd termination in the PyDev debugger in Eclipse. Running the following works fine.
import pandas as pd
def main():
print('hello')
pd.Series([])
if __name__ == '__main__':
main()
When I debug the same code with a breakpoint on line 1 it works so far.
If I step over one step (F6 or pressing the button) however it terminates itself with an ugly exit value (-1073741819), but no error in the console.
This happens when I debug almost any of the code I have except for the most basic things. I tried running "eclipse.exe -clean" but it didn't seem to clear the problem.
Edit:
It is clearly installing pyinstaller that is the issue
conda install -c conda-forge pyinstaller
if I revert to a previous revision the debugger works again. Oddly I don't even need to restart eclipse for it to fix itself.

pydev debug python program started by another program

I have a C++ program that starts two instances of a python program in separate processes. I have a problem in the python program which causes it to not to display any logging information. The python program instances communicate with the C++ program via Stdin and Stdout/Stderr. I want to, if possible, to run one instance of the program under the Pydev debugger since the C++ program is complaining about receiving invalid input from both of the python programs. The python program can do nothing without communication to the C++ program so running the python program in isolation does not help.
Because Stdin and Stdout are used for inter-process communication so I cannot use print() statements but must use python logging but the program seems to be crashing before anything can reach the log file. The python program was working before my last changes so the architecture is functioning OK.
Any suggestions?
My suggestion for debugging the Python program launched from the C++ program would be using the remote debugger feature:
http://www.pydev.org/manual_adv_remote_debugger.html
(that way you can add programatically start the debugger on the python code wherever you'd like without needing to do anything special to launch it).

Command line console for Unity 3d C#

Is there a command line console that I can try and execute lines of code in Unity?
Something like the Chrome console for javascript, or running python on the command line?
I am on windows 8.
I saw the immediate window in MonoDevelop, but it didn't seem to work without a debug session, and when I was debugging it said it wouldn't run when the application was running:
> this
The expression can't be evaluated while the application is running.
> this
Debug session not started.
It probably wanted to be at a breakpoint, which was not obvious to get working and kept crashing when I tried various ideas. I would rather just use the console independently from debugging - just to experiment with syntax etc.
What is the easiest way to bring up a console for executing lines of C# unity code?

Python & Eclipse - Get curent filename error

I decided to start using Eclipse to code in python, but I am having problems getting the filename of the current script. To get the current filenam I use:
#!/usr/bin/env python2.7
import os
os.path.basename(__file__)
My code works flawlessly when using the bash terminal or Geany, but with Eclipse Interactive Console I get:
name '__file__' is not defined
Any ideas?
UPDATE
When I run my code using python filename.py it works perfectly, but when I try running it from the python or ipython consoles I get the same error
Ok, found an alternative method that works with PyDev's interactive console from:
How to properly determine current script directory in Python?
The solution is:
#!/usr/bin/env python2.7
import inspect
filename = inspect.getframeinfo(inspect.currentframe()).filename.split('/')[-1]