Cannot launching app with python's subprocess.call method gives error
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Cannot launching app with python's subprocess.call method gives error
Hi,
i'm new to the forum and i hope u guys can help me out.
I'm working with centos 7 gnome desktop and i'm writing a python script that runs inside Autodesk Maya. All works well until the time when i want to launch programmatically a video player.
The application is the melt video engine and if i type this on the command line:
Code:
melt /home/jiceq/Desktop/pelota.mov
the video starts correctly so it works perfectly from there. Conversely, if i do it from python it gives me an error.
Code:
mlt_repository_init: failed to dlopen /usr/lib64/mlt/libmltavformat.so
(/lib64/libavfilter.so.4: symbol sws_isSupportedEndiannessConversion, version LIBSWSCALE_2 not defined in file libswscale.so.2 with link time reference)
No LADSPA plugins were found!
Check your LADSPA_PATH environment variable.
I'm quite convinced the configuration from the gnome-terminal is not the correct one. Maybe the command6 is incorrect.
I've tried to launch other installed programs and they fail to launch from python but not from the command line.
Can u give me a hint on this?
Maybe this isnt the right spot maybe it should be on programming forum...
mlt_repository_init: failed to dlopen /usr/lib64/mlt/libmltavformat.so
so, create a shell script and use
#!/bin/bash
Stick env ($PATH) variables here.
/path/to/melt /home/jiceq/Desktop/pelota.mov
save and exit. chmod etc.
command6 = ['gnome-terminal', '-x', 'bash', '-c', '/home/x/script.sh']
subprocess.call(command6, shell=True, env=os.environ.copy(),stdout=PIPE)
Not to doubt dugan, but is shell=True even necessary if we open/exec/run a terminal emulator that opens a shell already?
Unless this for some visual feedback (cheap debugger?)
Doesn't seem very pythonic to me. But I'm new to the game.
Dugan, as far as i can tell since i searched for it on google, subprocess.call admits a string as the commands but will try your point as soon as i can since it seems safer and the right way to do it. I don't have much hope it will work since it's quite the same as the string but will try anyway just in case.
On the other hand my other problem is i dont know what's the configuration the shell loads when i launch it manually hence, i cannot be sure what ENV variables to add to the shell script or even if it is a problem of env variables.
Had to set "shell=False" otherwise it only launches a terminal and nothing more.
The result is the same as i had with the string command:
Code:
mlt_repository_init: failed to dlopen /usr/lib64/mlt/libmltavformat.so
(/lib64/libavfilter.so.4: symbol sws_isSupportedEndiannessConversion, version LIBSWSCALE_2 not defined in file libswscale.so.2 with link time reference)
Maybe executing a shell script that previously loads proper configuration is the way to go.... Any ideas on this? I'm using Centos 7. It has to be something wrong with the terminal's config not being the same....
When i launch the terminal through subprocess.call it gives the error i previously posted. But then i tried to call the videoplayer manually in the same terminal and didn't work either, whereas if i open a new terminal it works.
Furthermore, i've discovered that if in that terminal i type "ldconfig" with root privileges and then i call manually de videoplayer.... it works!!!!!
So, my conclusion:
What is more precisely preventing the videoplayer to be launched is that the terminal's config does not recognize the path to the dynamic libraries, rebuilding the ld.so.cache makes it load and recognize the paths which is what ldconfig apparently does. The only problem is that it requires root permissions to write the cache.
So i got a pathway here, i only need to automate it through a script something like:
#!/bin/bash
sudo ldconfig
melt "!@"
and be able to do it without asking for a password. For this ive tried to edit the /etc/sudoers list and add my user but no chance!
You guys certainly know how to do this!! Any help?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.