# \#python

**URL:** https://forums.swift.org/tag/python/38.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Swift2Python: like PythonKit except modernized for Swift concurrency](https://forums.swift.org/t/swift2python-like-pythonkit-except-modernized-for-swift-concurrency/87691)

<div class="topic-metadata">

**Author:** [@zbenwhite](https://forums.swift.org/u/zbenwhite)\
**Replies:** 1\
**Last updated:** [June 28, 2026, 4:24am UTC](https://forums.swift.org/t/swift2python-like-pythonkit-except-modernized-for-swift-concurrency/87691 "2026-06-28T04:24:59Z")

</div>

I made a new alternative to PythonKit. It is modern, works together with Swift concurrency, and automatically handles the GIL for you. It's called Swift2Python. It is here: GitHub - zbenwhite/Swift2Python: Swift ↔ Pyt…

---

## [PythonKit not finding Python 3 library](https://forums.swift.org/t/pythonkit-not-finding-python-3-library/45381)

<div class="topic-metadata">

**Author:** [@carltongibson](https://forums.swift.org/u/carltongibson)\
**Replies:** 12\
**Last updated:** [January 31, 2025, 7:17am UTC](https://forums.swift.org/t/pythonkit-not-finding-python-3-library/45381 "2025-01-31T07:17:35Z")

</div>

Hi. :waving\_hand: I'm experimenting with @pvieito's great looking PythonKit. I'm having a weird dlopen/search path issue. I'm wondering if anyone can advise? Problem Following the project README I have a very simple h…

---

## [Unable to use python modules that are installed on my mac with PythonKit](https://forums.swift.org/t/unable-to-use-python-modules-that-are-installed-on-my-mac-with-pythonkit/71777)

<div class="topic-metadata">

**Author:** [@SunnyFlops](https://forums.swift.org/u/SunnyFlops)\
**Replies:** 20\
**Last updated:** [May 18, 2024, 9:35pm UTC](https://forums.swift.org/t/unable-to-use-python-modules-that-are-installed-on-my-mac-with-pythonkit/71777 "2024-05-18T21:35:57Z")

</div>

So, I'm trying to use pyserial and regular expressions with PythonKit, which I have pip installed onto my mac, but I cannot use it, and it runs into the following error: PythonKit/Python.swift:707: Fatal error: 'try!' e…

---

## [Accelerate in Swift is slower than NumPy in Python for matrix multiplication](https://forums.swift.org/t/accelerate-in-swift-is-slower-than-numpy-in-python-for-matrix-multiplication/71365)

<div class="topic-metadata">

**Author:** [@wigging](https://forums.swift.org/u/wigging)\
**Replies:** 36\
**Last updated:** [April 24, 2024, 2:26pm UTC](https://forums.swift.org/t/accelerate-in-swift-is-slower-than-numpy-in-python-for-matrix-multiplication/71365 "2024-04-24T14:26:33Z")

</div>

I'm performing matrix multiplication in Swift using the vDSP\_mmulD and cblas\_dgemm functions from Accelerate as shown below. Each matrix is a square N x N matrix. The code is in a file named main.swift and is compiled wi…

---

## [Run ARM64 Python from an x86\_64 Application Through Rosetta on Apple Silicon](https://forums.swift.org/t/run-arm64-python-from-an-x86-64-application-through-rosetta-on-apple-silicon/70773)

<div class="topic-metadata">

**Author:** [@Aymeric](https://forums.swift.org/u/Aymeric)\
**Replies:** 0\
**Last updated:** [March 18, 2024, 10:41pm UTC](https://forums.swift.org/t/run-arm64-python-from-an-x86-64-application-through-rosetta-on-apple-silicon/70773 "2024-03-18T22:41:10Z")

</div>

Hello, Our application currently runs through Rosetta on Apple Silicon. It relies on Python dependencies that utilize kernel extensions (kext). Since kext cannot be executed through Rosetta, we're facing a challenge. W…

---

## [Does anyone know if Pythonkit supports subthreads?](https://forums.swift.org/t/does-anyone-know-if-pythonkit-supports-subthreads/68583)

<div class="topic-metadata">

**Author:** [@willon](https://forums.swift.org/u/willon)\
**Replies:** 8\
**Last updated:** [November 26, 2023, 4:20pm UTC](https://forums.swift.org/t/does-anyone-know-if-pythonkit-supports-subthreads/68583 "2023-11-26T16:20:48Z")

</div>

Anyone know how to do that let Pythonkit run in a subthread? I really create a serial subthread for Pythonkit but it's always occur " #1 0x0000000105729c54 in \_pthread\_cond\_wait ()" All of my code and error is below: …

---

## [Trouble loading python file using PythonKit](https://forums.swift.org/t/trouble-loading-python-file-using-pythonkit/48008)

<div class="topic-metadata">

**Author:** [@CPcommunity](https://forums.swift.org/u/CPcommunity)\
**Replies:** 1\
**Last updated:** [January 28, 2023, 10:34pm UTC](https://forums.swift.org/t/trouble-loading-python-file-using-pythonkit/48008 "2023-01-28T22:34:51Z")

</div>

I have followed the various tutorials so that I can run a python file from within Swift. I have gotten everything set up and run the file, but I get the following error. Could not access PythonObject member I have to…

---

## [Pythonkit: No such file or directory](https://forums.swift.org/t/pythonkit-no-such-file-or-directory/54762)

<div class="topic-metadata">

**Author:** [@weinamao](https://forums.swift.org/u/weinamao)\
**Replies:** 0\
**Last updated:** [January 20, 2022, 11:57pm UTC](https://forums.swift.org/t/pythonkit-no-such-file-or-directory/54762 "2022-01-20T23:57:45Z")

</div>

Running python scripts with @pvieito's PythonKit , but hit this error: PythonKit/Python.swift:598: Fatal error: 'try!' expression unexpectedly raised an error: Python exception: \[Errno 2\] No such file or directory: 'ast…

---

## [Using PythonKit in Xcode Playground and project](https://forums.swift.org/t/using-pythonkit-in-xcode-playground-and-project/45410)

<div class="topic-metadata">

**Author:** [@xareelee](https://forums.swift.org/u/xareelee)\
**Replies:** 5\
**Last updated:** [December 25, 2021, 8:48am UTC](https://forums.swift.org/t/using-pythonkit-in-xcode-playground-and-project/45410 "2021-12-25T08:48:07Z")

</div>

Hi, I'm trying using PythonKit in my Xcode project and Playground for data science with Swift instead of Jupyter Notebook. I have some questions about PythonKit. 1. Specifying python path in my Xcode project and Playgr…

---

## [Python interop with PythonKit](https://forums.swift.org/t/python-interop-with-pythonkit/28386)

<div class="topic-metadata">

**Author:** [@elhoov](https://forums.swift.org/u/elhoov)\
**Replies:** 8\
**Last updated:** [June 20, 2021, 3:43pm UTC](https://forums.swift.org/t/python-interop-with-pythonkit/28386 "2021-06-20T15:43:47Z")

</div>

I've been really interested in the Python integration provided by Swift for Tensorflow and I got the impression from reading the README that PythonKit (GitHub - pvieito/PythonKit: Swift framework to interact with Python.)…

---

## [What will happen to PythonKit now that Swift for Tensorflow has been shut down?](https://forums.swift.org/t/what-will-happen-to-pythonkit-now-that-swift-for-tensorflow-has-been-shut-down/44767)

<div class="topic-metadata">

**Author:** [@hggz](https://forums.swift.org/u/hggz)\
**Replies:** 4\
**Last updated:** [February 15, 2021, 4:43pm UTC](https://forums.swift.org/t/what-will-happen-to-pythonkit-now-that-swift-for-tensorflow-has-been-shut-down/44767 "2021-02-15T16:43:04Z")

</div>

The title is pretty self explanatory. Is it too early or does anyone know what the direction for PythonKit is going to be like? Are there any maintainers that are active in its development or was it mainly the team from …

---

## [PythonLambda – adding Python Lambdas to Swift / PythonKit](https://forums.swift.org/t/pythonlambda-adding-python-lambdas-to-swift-pythonkit/38905)

<div class="topic-metadata">

**Author:** [@strictlyswift](https://forums.swift.org/u/strictlyswift)\
**Replies:** 7\
**Last updated:** [August 26, 2020, 1:12pm UTC](https://forums.swift.org/t/pythonlambda-adding-python-lambdas-to-swift-pythonkit/38905 "2020-08-26T13:12:33Z")

</div>

Hi all, I am interested in using Swift for data science, and have of course started using PythonKit to interface with numpy, pandas etc. A challenge that one quickly faces when using many Python APIs is their reliance…

---

## [PythonKit adding spectral\_norm](https://forums.swift.org/t/pythonkit-adding-spectral-norm/37123)

<div class="topic-metadata">

**Author:** [@jbmaxwell](https://forums.swift.org/u/jbmaxwell)\
**Replies:** 1\
**Last updated:** [June 2, 2020, 10:25pm UTC](https://forums.swift.org/t/pythonkit-adding-spectral-norm/37123 "2020-06-02T22:25:47Z")

</div>

I'm using PythonKit to load and run a PyTorch model. I had it working well but my latest version of the trained model adds spectral normalization and I'm not sure how to add it. In Python, I followed a process of definin…

---

## [Swift 5.3 Windows: no such module 'Python'](https://forums.swift.org/t/swift-5-3-windows-no-such-module-python/37065)

<div class="topic-metadata">

**Author:** [@ofermode](https://forums.swift.org/u/ofermode)\
**Replies:** 11\
**Last updated:** [June 2, 2020, 3:00pm UTC](https://forums.swift.org/t/swift-5-3-windows-no-such-module-python/37065 "2020-06-02T15:00:49Z")

</div>

I'm trying to extend the HelloWorld example here: git://github.com/compnerd/swift-build-examples /SourceCache/swift-build-examples by simply adding this line at the top of HelloWorldCore.swift: import Python building…

---

## [Using PythonKit with complex python modules](https://forums.swift.org/t/using-pythonkit-with-complex-python-modules/34501)

<div class="topic-metadata">

**Author:** [@NCrusher](https://forums.swift.org/u/NCrusher)\
**Replies:** 1\
**Last updated:** [May 18, 2020, 9:02pm UTC](https://forums.swift.org/t/using-pythonkit-with-complex-python-modules/34501 "2020-05-18T21:02:19Z")

</div>

I've only been leaning Swift for about six months, but thanks to some amazing help from @SDGGiesbrecht, I've come a long way. I've been looking for a package or framework to fulfill a particular purpose I have, and have…

---

## [Python 3 support for building Swift Toolchain](https://forums.swift.org/t/python-3-support-for-building-swift-toolchain/27020)

<div class="topic-metadata">

**Author:** [@Ron\_Olson](https://forums.swift.org/u/Ron_Olson)\
**Replies:** 29\
**Last updated:** [April 17, 2020, 12:29pm UTC](https://forums.swift.org/t/python-3-support-for-building-swift-toolchain/27020 "2020-04-17T12:29:29Z")

</div>

Hey all- Fedora is actively deprecating Python 2 for Python 3 and as of just a few days ago, the change was made that /usr/bin/python is no longer symlinked to /usr/bin/python2 but /usr/bin/python3. I rebuilt the latest…

---

## [Concurrent Swift and Python interop](https://forums.swift.org/t/concurrent-swift-and-python-interop/32956)

<div class="topic-metadata">

**Author:** [@rex-remind](https://forums.swift.org/u/rex-remind)\
**Replies:** 2\
**Last updated:** [January 23, 2020, 10:54pm UTC](https://forums.swift.org/t/concurrent-swift-and-python-interop/32956 "2020-01-23T22:54:28Z")

</div>

I've been looking at python/swift interop and from what I've been able to piece together from github, Python.import calls dlopen on the users path to python. Some questions I have are: Does dlopen spin up an actual Pyt…

---

## [Using Python with Swift](https://forums.swift.org/t/using-python-with-swift/10754)

<div class="topic-metadata">

**Author:** [@alper](https://forums.swift.org/u/alper)\
**Replies:** 4\
**Last updated:** [January 11, 2020, 8:24pm UTC](https://forums.swift.org/t/using-python-with-swift/10754 "2020-01-11T20:24:14Z")

</div>

Now that the proposal has been merged is there an updated version of PythonGlue.swift that we can use? What can I do right now to be able to use Python in my swift project?

---

## [PythonCodable: Swift framework to efficiently bridge objects from Python to Swift](https://forums.swift.org/t/pythoncodable-swift-framework-to-efficiently-bridge-objects-from-python-to-swift/31778)

<div class="topic-metadata">

**Author:** [@pvieito](https://forums.swift.org/u/pvieito)\
**Replies:** 0\
**Last updated:** [December 17, 2019, 8:24pm UTC](https://forums.swift.org/t/pythoncodable-swift-framework-to-efficiently-bridge-objects-from-python-to-swift/31778 "2019-12-17T20:24:21Z")

</div>

For anyone interested :slight\_smile:: PythonCodable Swift framework to efficiently bridge objects from Python to Swift. Requirements PythonCodable requires Swift 5 or higher. Usage PythonCodable builds on PythonKit t…

---

## [Python.import with Xcode 10](https://forums.swift.org/t/python-import-with-xcode-10/18855)

<div class="topic-metadata">

**Author:** [@Maxim\_Veksler](https://forums.swift.org/u/Maxim_Veksler)\
**Replies:** 2\
**Last updated:** [January 15, 2019, 4:40am UTC](https://forums.swift.org/t/python-import-with-xcode-10/18855 "2019-01-15T04:40:32Z")

</div>

Hi, Dynamic member lookup was implemented in Swift 4.2. Why is it then that when I do Python.import I'm getting an error? I found a way to work around this by installing the TensorFlow toolchain and configuring the bu…
