I’ve been trying to figure out how to launch an external program from Julia, and I am stumped.
In Python, I can do this:
os.system("exec python -m PyQt5.uic.pyuic evaluate.ui -o ui_Evaluate.py -x")
I’ve tried most of the examples in this thread: Better support for running external commands - #25 by StevenSiew
…but none of them work.
For example, even a simple line like this
run(Cmd(`exec python`))
gives me an error:
ERROR: IOError: could not spawn `exec python`: no such file or directory (ENOENT)
or even
run(Cmd(`python`))
ERROR: IOError: could not spawn `python`: no such file or directory (ENOENT)
The “bashit()” example in the above mentioned thread gives the same error.
Finally, I decided to try to use PyCall, which should allow me to use the same code I’ve successfully been using in Python. Instead…
os = pyimport("os")
os.system("exec python -m PyQt5.uic.pyuic evaluate.ui -o ui_Evaluate.py -x")
which yields: sh: line 0: exec: python: not found
Yet, that works in Python, and it works in the command line. So why can’t python be found when calling os.system() from Julia via PyCall? After reading the documentation for Python’s os.system(), apparrently it just calls “Standard C function system()
”. So why not skip Python and use ccall instead?
@ccall system("exec python -m PyQt5.uic.pyuic evaluate.ui -o ui_Evaluate.py -x"::Cstring)::Cstring
Failure: sh: line 0: exec: python: not found
So what am I doing wrong? Why does system() work in Python, but but gives me grief when called from Julia, using either PyCall or CCall?