Questions tagged [swift-pythonkit]

28 questions
8
votes
4 answers

I can't import Python modules in Xcode 11 using PythonKit

I am now using Swift Package Manager. Using that, I imported PythonKit into my Swift project. I can't import the Python modules using the PythonKit now. It asks me to set the PYTHON_LIBRARY path but I don't know how to do that. Can anyone help…
Alan Z
  • 803
  • 1
  • 7
  • 13
6
votes
3 answers

PythonKit error "Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library"

I'm using PythonKit with XCode to call spaCy API from swift code. Installed PythonKit from Home-brew, imported it in my project and it built well; however, at runtime I got the error: Python library not found. Set the PYTHON_LIBRARY environment…
5
votes
1 answer

PythonKit crashes on start due to dlopen returning nil

I'm trying to use some Python Code in my Swift project with PythonKit. In order to do that, I've downloaded the new Xcode 11 to add PythonKit as Swift Package. After adding PythonKit with Swift Package, I have these project dependencies right here.…
Anissa
  • 51
  • 3
3
votes
1 answer

Using Python modules in Swift and Pythonkit

I was looking to get some help or clarification of the limitations of using PythonKit in Swift. Well I say PythonKit, I actually installed the Tensorflow toolchain in Xcode as I couldn't get Pythonkit to work on its own as a single dependancy…
thopri
  • 33
  • 3
3
votes
0 answers

Utilizing python code within swift using 3rd party software

so I'm pretty new to both swift and stack, but I have a problem with implimenting Pythonkit. But basically to provide a short summary, the kit basically allows you to be able to utilize python inside of swift (using certain swift functions in order…
2
votes
0 answers

How do you connecting a python module to a Swift file in a different directory?

I've been trying to learn how to build Swift programs. For my first Swift program, I decided to build a program where I could log my hours for work. In Swift, I've already made a user interface, but I wrote a python program that runs the clock and…
2
votes
2 answers

Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library

I have built a macOS application that using the python language. With the help of PythonKit, I'm using Python in swift. When I'm trying to use python then it getting an exception. Python library not found. Set the PYTHON_LIBRARY environment variable…
2
votes
1 answer

XCode/Swift and Python files - Want to embed a Python.py file in an XCode project

I want to create a Swift app that calls some embedded Python.py files using PythonKit. In the docs and a sample file it says that I should use let sys = Python.import("sys") sys.path.append("/Users/mlboy/PythonTest/") // path to your Python file's…
iPadawan
  • 898
  • 1
  • 12
  • 23
2
votes
0 answers

PythonKit Crashing Swift Project

I'm building an ios app using Xcode (11.6) and Swift (5.1.3). The backend of my app relies on a Python library so I'm integrating a python script into my project using the PythonKit library (I'll leave a link to the github below). I added the…
1
vote
0 answers

Using ffmpeng in swift code using PythonKit

I have a python script that uses ffmpeng. I installed it using brew install ffmpeg. If I run the python script on python IDE it runs perfectly. But I wanted to run this python script on my macOS app, so using PythonKit I tried running it: static…
Seungjun
  • 874
  • 9
  • 21
1
vote
1 answer

Py_Initialize undefined error in Xcode while integrating Python in iOS project

I am trying to integrate Python in iOS app. Here is the contentview file import SwiftUI import Python import PythonKit struct ContentView: View { @State private var showingSheet = false var body: some View { var…
user2129623
  • 2,167
  • 3
  • 35
  • 64
1
vote
1 answer

PythonKit can't find PYTHON_LIBRARY for Python3

I'm using PythonKit in my Swift project for MacOS. At the moment I'm using Python 2.7 but from MacOs 12.3 it isn't no more supported so I'm trying to migrate to Python 3 but it doesn't work. func applicationDidFinishLaunching(_ notification:…
1
vote
1 answer

Xcode 13 won't stay paused at breakpoint

I'm on Xcode 13 GM (13A233) and I'm noticing that it won't stay paused when it hits a breakpoint. It stops, but about a minute later it just resumes. Is there a new default setting that might cause this? I don't see anything relevant in "Behaviors,"…
jbm
  • 1,248
  • 10
  • 22
1
vote
1 answer

Executing python from swift via bash: "can't open file...[Errno 1] Operation not permitted"

I am learning how to make apps for mac, and I am starting with an app to manage my many discord bots. Essentially, the goal is to have many switches to turn bots on and off, which requires executing the python files for the bots, written using…
Nathan Wolf
  • 336
  • 3
  • 12
1
vote
1 answer

PythonKit for OSX Swift project suddenly not finding modules

I built a MacOS app using PythonKit to run some scripts and return the data. I had it running with no issues the other day but now it crashes when trying to load the script file. I've verfied the path to the file is correct and have run the Python…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
1
2