-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys.executable generates error if a white space is present in the python executable path #119
Comments
to add @casella in the loop |
|
Hi Christoph, I tried the suggestion but the check_output fails:
The difficult is to find a solution that works with both |
Maybe I found a solution, we have to use two different path, the first for the |
TBH, I'm confused why popen is used at all, that's typically a bit low-level api, but I don't have a good grasp of the codebase. |
Some month ago the use of
sys.executable
function has been introduced in thetest.py
script in order to get the current python executable path. I suppose that this has be done to make more general the script because some python installations have different commands to start them (e.g., python3 or similar).This solution generates issues if some white spaces are present in the python path executable, for example on my windows machine the python executable path is the following:
C:\Program Files\Python311\python.exe
as, I think, in the most of the windows installations.
The output from the
sys.executable
function is the following:'C:\\Program Files\\Python311\\python.exe'
By using this path the command generated to run the testmodel.py script is like the following:
cmd = C:\Program Files\Python311\python.exe testmodel.py --win --msysEnvironment=ucrt64 --libraries=C:\LibTest\master --ompython_omhome= STTlibrary_STTlibrary.Components.DigitalController.Examples.ControlledTank.conf.json > files/STTlibrary_STTlibrary.Components.DigitalController.Examples.ControlledTank.cmdout 2>&1, STTlibrary_STTlibrary.Components.DigitalController.Examples.ControlledTank, 300
that generates the following error on the subprocess call:
That means that the shell does not resolve correctly the python executable path.
I tried to modify the python executable path as following:
'C:\\\"Program Files\"\\Python311\\python.exe'
that works fine if used in the win terminal as:
'C:\"Program Files"\Python311\python.exe
but in this case i get the following error
here below the
popenargs
andkwargs
values:(['C:\\"Program Files"\\Python311\\python.exe', 'testmodel.py', '--help'],) {'stderr': -2}
I tried with others combination of commas or backslash characters but the result doesn't change, so at the moment the unique solution that I can propose is the following change in the script
that is not so elegant but works...
Any suggestion?
The text was updated successfully, but these errors were encountered: