1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How can one python script launch another python script using a different virtual...

Discussão em 'Python' iniciado por Stack, Setembro 12, 2025.

  1. Stack

    Stack Membro Participativo

    First, I have researched this question and found this Stack Overflow Post. My situation is a little different so I decided to open a new question.

    Second, a little about me. I'm a retired geek with some python experience, from the pre-venv era. I say this to forestall any "don't ask me to do your homework" responses. Also, I have a desire to learn more about venvs.

    With that out of the way:

    I have an astrophotography application which I run on Ubuntu Linux 24.04.2 LTS. This application has a facility for launching python scripts. It does so using its own venv. They supply a python script to launch a third party executable that sharpens an image that the main application is working with. This third party executable optionally can use GPU acceleration given the presence of a suitable GPU on the system running the script. This GPU detection functionality depends on code in the main application's venv.

    Another possibly important detail is that the third-party executable is itself compiled from a python script, which presumably uses a venv. It is not c++ or other similar language.

    The situation is when the script is run from the application, an error message is emitted saying that GPU acceleration is not available, and the process drops back to CPU processing which takes perhaps perhaps 100 times as long. This error message is incorrect.

    How do I know this? The third party executable can be successfully run standalone when the much faster GPU processing can be observed.

    To do that one must manually copy the file to be processed to a specific directory where the standalone executable expects to find it. If running from the application, the existing python script automatically copies the selected file to the executable's input directory, while also copying the processed file back from the executable's output directory to the same directory where the original image was located, a very convenient feature.

    The problem lies with the application's python venv, which incorrectly detects whether or not the GPU support is available. Apparently, this is one big thorny mess which the application's developers are working on. When run standalone, the executable uses the system's python venv (remember it is compiled python).

    What I would like to do in the meantime is to develop a script that can be run from the application that handles all the file copying before and after launching another python script using the system venv which launches the executable. In other words, to avoid the problematic GPU detection logic, since I know that in my case the GPU is suitable.

    Is this possible and if so, what would be the best way to do it?

    Continue reading...

Compartilhe esta Página