Linux Ubuntu how to start standard application scribus from python eclipse anaconda

81 views Asked by At

I edited my question, hope it is described better now.

I am working on a software that gives me a nice PDF with lots of matplotlib graphics, depending on the data I get. So think of a database of pages and then the software decides which pages are chosen and filled with changed images, The text stays the same. So for instance for data1 I get page1-4 and page7 and page 9. For data2 I get page1-4 and page6. Saved as PDF. I am doing this manually with Quark which needs to be changed. I hope I can figure out the scripting to do so.

But for starters I cant start scribus from the developing enviroment. Eclipse Anaconda on Ubuntu.

import subprocess
subprocess.run('scribus')

works fine in terminal, but gives me an error in Eclipse which I cant figure out.

File "/home/b256/anaconda3/envs/test/lib/python3.7/site.py", line 178 file=sys.stderr) ^ SyntaxError: invalid syntax

This seems to be some Python 2 error in the site.py file

???? Is this some anaconda python path error ??

1

There are 1 answers

4
a.l.e On

It's not really clear to me, what you want to achieve, but you're welcome to have a look at a script of mine:

https://github.com/aoloe/scribus-script-repository/blob/master/imposition/imposition.py

This is probably a bit more complex than what you are trying to achieve:

  • the script gets started from the terminal,
  • if it notices that it has not been started from inside of Scribus (the exception on import scribus)...
  • ... it starts Scribus with itself as the Script to be run.
  • the script runs again, this time from inside of Scribus...
  • ... now there is no exception when importing scribus and the body of the script runs.

Of course, it's simpler if you start a script that launches Scribus with other scripts.

For you the most important line is probably:

call(['scribus', '-g', '-py', sys.argv[0]] + arguments + ['--', file])

It's starting Scribus from Python

  • with as little GUI as possible (-g) and
  • launches the script sys.argv[0]
  • with a few arguments and
  • after the -- tells Scribus what file to open.