Message Boards Message Boards

Run external python script in graphical mode

Posted 4 years ago

I need to run a python script with opencv library in Mathematica. The mathematica command RunProcess[{"python3",ExpandFileName@"~/Documents/8_pyMathematica/pyMM/head_snake/ mm_call_python/show.py "}] The code of show.py file : import sys import cv2 src = cv2.imread("test.jpg") cv2.namedWindow("input", cv2.WINDOW_AUTOSIZE) cv2.imshow("input", src) cv2.waitKey(0) cv2.destroyAllWindows() test.jpg is shown as follow. enter image description here

When I run the Mathematica command, I get an error <|"ExitCode" -> 1, "StandardOutput" -> "", "StandardError" -> "Traceback (most recent call last): File \"/home/zhou/Documents/8_pyMathematica/pyMM/head_snake/mm_call_python/show.py\", line 13, in <module> import cv2 ImportError: /usr/lib/x86_64-linux-gnu/libatspi.so.0: undefined symbol: g_type_class_adjust_private_offset "|>

I refer to the question: https://mathematica.stackexchange.com/q/115069/72466. I try to use RunProcess[{"LD_LIBRARY_PATH=python3",ExpandFileName@"~/Documents/8_pyMathematica /pyMM/head_snake/mm_call_python/show.py "}] It returns a error RunProcess: Program LD_LIBRARY_PATH=python3 not found. Check Environment["PATH"]. The command is ran on Ubuntu 16.04. What is the general method to handle this kind of issues and how to fix this problem?

POSTED BY: Yunhu Zhou
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract