我想从macOS应用程序通过NSTask执行python脚本。我的代码如下:
NSString *image1Path = [[NSBundle mainBundle] pathForResource:@"a1" ofType:@"jpg"];
NSString *image2Path = [[NSBundle mainBundle] pathForResource:@"a2" ofType:@"jpg"];
NSString *predictorPath = [[NSBundle mainBundle] pathForResource:@"shape_predictor_68_face_landmarks" ofType:@"dat"];
NSString *pythonScriptPath = [[NSBundle mainBundle] pathForResource:@"faceMorph" ofType:@"py"];
NSTask *task = [NSTask new];
[task setExecutableURL:[NSURL fileURLWithPath:@"/usr/bin/python"]];
[task setArguments:@[pythonScriptPath,@"-p1",image1Path,@"-p2",image2Path,@"-a",@"0.5",@"-ex",@"/Users/fofo/a3.jpg",@"-predictorpath",predictorPath]];
[task launch];
[task waitUntilExit];
如果禁用沙盒,脚本运行正常。但是,如果启用沙箱,则输出如下:
Traceback (most recent call last):
File "/Users/fofo/Library/Developer/Xcode/DerivedData/FaceMorph_macOS-cmfgvhivheuzioacarvvcyjpokyp/Build/Products/Debug/FaceMorph macOS.app/Contents/Resources/faceMorph.py", line 4, in <module>
import cv2
ImportError: No module named cv2
非常感谢您的任何建议。谢谢
目前没有回答
相关问题 更多 >
编程相关推荐