Error in import PythonKit in CLion

Hi all,

I could use some tips on how to setup PythonKit for local use. I installed the swift4TF toolchain, and set it as the toolchain path for the given project in CLion, using the Swift plug-in. I included the dependency for PythonKit in Package.swift:

.package(url: "https://github.com/pvieito/PythonKit.git", .branch("master")), 

However, just trying to import PythonKit into main.swift yields a bewildering error message. If anyone could clue me into how to fix it, I would be grateful. The error message reads as follows:

Compiling Swift_Cpp main.swift
error: compiling for macOS 10.10, but module ‘PythonKit’ has minimum deployment target of macOS 10.13: /Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.11.xctoolchain/usr/lib/swift/macosx/PythonKit.swiftmodule/x86_64.swiftmodule

It’s a basic use case. I want to use Swift to import a .txt file with 18 2d arrays of 45 x 25 (18 toy images stacked depthwise), taken from an image-processing pipeline, and apply S4TF to fit a basic modeling framework to it, then render the original image with overlaid probabilities for each region of interest.

@clattner @marcrasi I opened an issue at this link: https://github.com/tensorflow/swift/issues/556.

I represent an academic community, a research group that works with medical imaging. We’re trying to use openCV (wrapped with Swift or integrated with S4TF), to pass arrays back and forth from a Python-based convolutional network. Is this feasible?

@jeremy @sgugger I/O with a cloud-based notebook, like Google Colab is not a practical solution for us, because we want the whole image-processing and predictive-analytics framework to work on an embedded device, like one for medical imaging that can be updated during a procedure. Do you have any intuition as to why CLion with the S4TF toolchain cannot import PythonKit, for a SwiftCV treatment of medical imaging in real-time?

Sorry for the slow reply, I just posted a response on your issue. I believe this is an artifact of building for macOS, where Swift and Swift Package Manager versions can determine compatibility with specific OS versions. By default, Swift Package Manager tries to target OS versions as far back as it can, but I think some newer capabilities of PythonKit or related packages can only be deployed to macOS 10.13. The fix I provided in that issue (which we use in tensorflow/swift-models) should let you build on macOS. You won’t see this error on any other platform, like Colab or embedded Linux, it’s macOS-specific.

I’d love to talk more about your specific application and how we can enable that. There certainly seems like there might be more performant ways to accomplish the data processing you need, especially on embedded devices. Feel free to drop by our discussion group or to email me directly at bradlarson at google.

1 Like

Thank you! How then would you integrate Swift with a performant version of openCV? That’s the current bottleneck.