I’m migrating various python scripts from windows to linux (windows 8, debian 10.8, python 3.7); in one of them the results were shown in an excel file:
xlsx_app = r'C:Program FilesLibreOfficeprogramscalc.exe'
Popen ([xlsx_app, fname])
(fname is the path to the excel file)
And now on linux I tried:
p = Popen(['libreoffice', '--calc', fname])
But it just opens calc and then it closes … I’ve already tried using "call", "PIPE" , "shell = False", and it’s always the same – also tried without the ‘–calc’ parameter.
Is there a particular way to open the calc files with python in linux?
Thanks in advance,
2
Answers
Thanks to Rahul Bharadwaj I realized that the problem relies somewhere else... don't know where, but, from this post, someone suggested to use 'xdg-open', which opens any file or url:
xdg-open
uses the application assigned to the file type or url, and I know it would be better to be able to pic the application, but in my case, if the file opens in the expected application (in this case, libreoffice calc) is enough.Thanks!
I vaguely remember having an issue with this but no longer remember exactly why I chose this solution.
My gut feeling, is that the
close_fds=True
parameter was what made the difference.I suppose it doesn’t matter, as you have a solution but I thought I’d throw in what I have used successfully on Linux, to fire up LibreOffice Calc in a separate process.