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 with the path to a Python library

But When I add the environment variable ( PYTHON_LIBRARY(Key) : path/of/Python.framework(value)) in schema.

And also checked Disable Library Validation in Hardened Runtime capability.

With the help of both, it runs without exception.

But when I try to build an archive using Developer ID.

It is getting the same exception.

I don't know why it's running without exception in debugging mode, not in release mode.

Any Suggestions...

There’s a lot to unpack here and it’s only tangentially related to Swift, and thus not something I want to dig into here on Swift Forums. If you open a thread over on Apple Developer Forums, we can pick things up there. Make sure to tag your question with Developer ID so that I see it.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple