Add external python packages to iOS app (Swift, PythonKit)

1.1k views Asked by At

I have an iOS application in Swift.
I was following this video and this usage guide to install Python inside my iOS app:

So now I can create .py files in my Resouces/Python/Resources folder, and run python functions.
But I have problems when I want to import external packages:

import cv2 <-------(!)
import os  <-------(!)
from image_similarity_measures.quality_metrics import rmse, ssim, sre <------- (!)

def myFunc():
    image = cv2.imread("/Users/user/Desk......<my path>...")

.............................
..... other logic steps .....
.............................

Obviously, xCode returns me an error, because I didn't install external packages:

PythonKit/Python.swift:706: Fatal error: 'try!' expression unexpectedly raised an error: Python exception: unindent does not match any outer indentation level (myscript.py, line 6)

I know that I can't just pip install ...

How to install 3-part python frameworks inside my Swift project?

0

There are 0 answers