Unable to find environment variable for Python library in the iPhone application project

Actually, I wanted to run a python file in the swift project for iPhone Application. I installed PythonKit from url (GitHub - pvieito/PythonKit: Swift framework to interact with Python.).
Then import PythonKit in viewcontroller and put print(Python.versionInfo) line in the viewload function as mention in the (Python interoperability  |  Swift for TensorFlow)

I tried to set the environment variable in the scheme. But every time got the error "Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library."
I put below the value
PYTHON_LIBRARY = "/opt/anaconda3/envs/myenv/lib/libpython3.9.dylib"
PYTHON_LIBRARY = "/Library/Frameworks/Python.framework/Versions/3.11/Python"

unable to read from there.

Please help me out with this issue @pvieito
Config:
Xcode: 14.1
Swift 5(Not SwiftUI)

Generally, setting PYTHON_LIBRARY to point to the Python dylib file should work (see also this example). But I do not think that there is a Python on iPhone.

I used below dylib file but unable to read.
PYTHON_LIBRARY = "/opt/anaconda3/envs/myenv/lib/libpython3.9.dylib"

Please look into the image which path is correct.

all through error

The first one is correct if the file exists.

But getting same error " Fatal error: 'try!' expression unexpectedly raised an error: Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library."

If you know anything missed from my side. Please

Try to create a macOS application.

In the Mac application is already done.
But want to implement for iOS application project where run the python file so the directly access the python function.

Thanks, if you know anybody who face that type problem and solved. Please share

As I already mentioned, there probably is no Python on the iPhone, and you are not allowed to include Python in your app.

1 Like

You are actually allowed under certain conditions. You can check the App Store, there are multiple Python IDEs / Jupyter Apps.

Ah, OK, but with limitations:

Except as set forth in the next paragraph, an Application may not download or install executable code. Interpreted code may be downloaded to an Application but only so long as such code: (a) does not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store, (b) does not create a store or storefront for other code or applications, and (c) does not bypass signing, sandbox, or other security features of the OS.

An Application that is a programming environment intended for use in learning how to program may download and run executable code so long as the following requirements are met: (i) no more than 80 percent of the Application’s viewing area or screen may be taken over with executable code, except as otherwise permitted in the Documentation, (ii) the Application must present a reasonably conspicuous indicator to the user within the Application to indicate that the user is in a programming environment, (iii) the Application must not create a store or storefront for other code or applications, and (iv) the source code provided by the Application must be completely viewable and editable by the user (e.g., no pre-compiled libraries or frameworks may be included with the code downloaded).