[Python] Different behavior when running a Python script from a command prompt vs. another...

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

  1. Stack

    Stack Membro Participativo

    I'm using USD Toolset that contains some batch scripts to start some of their tools. One of the batch scripts is to start their 'viewer', usdview, which is basically just a QT app to display some objects using the USD format, (more info here if you are interested).

    I'm trying to execute this same batch file from my Python script as follows:

    subprocess.Popen("usdview_gui.bat", stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NEW_CONSOLE)


    I'm able to successfully run this batch file from a command prompt but when trying to run the line above in my Python script (which is inside my Python app) I have the following error:

    ImportError: DLL load failed while importing _tf: The specified module could not be found


    Under the hood, the batch file is ultimately simply running a python script:

    @python "%~dp0usdview" %*


    I verified the python interpreter that is used by the Popen method and inside the command prompt and it seems to be the same. The usdview_gui batch file also calls another batch file to instantiate environment variables: call "%~dp0set_usd_env.bat".

    Continue reading...

Compartilhe esta Página