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

Skip to first unread message

Ravindra Sonkar

Jul 21, 2021, 6:27:24 AM7/21/21
to Swift for TensorFlow

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.

Screenshot 2021-07-17 at 2.19.54 PM.png

And also checked Disable Library Validation in Hardened Runtime capability.

Screenshot 2021-07-17 at 2.19.37 PM.png

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.

I had built whole application using Pythonkit But now problem with app distribution.It was showing my first exception when I started using Pythonkit.

Please help me out.

Message has been deleted
Message has been deleted

Satoshi Miyazaki

Jul 22, 2021, 5:37:08 AM7/22/21
to Swift for TensorFlow,
I am trying to understand what you mean by 'build an archive using Developer ID' . After archiving, you try to Distribute the app via Developer ID, correct ? This means that, the app is uploaded to Apple for the notarization. If the notarization is successful , you can export the notarized App to your local file system for distribution. Do you mean that this notarized app crash with the exception ? If so, you might have to set the environmental variable PYTHON_LIBRARY for your app. The following page will be helpful to set variable for App.

Note also that the directory, PYTHON_LIBRARY, depends on the system configuration. So when you distribute your app, you might have to ask your customers to set that variable appropriately. In my experience, python installed by third party such as anaconda frequently causes App crash. Python Library installed by Apple is usually OK but not 100 % OK. This is the most tricky part of App using PythonKit.  Good luck.

2021年7月21日水曜日 19:27:24 UTC+9

Ravindra Sonkar

Jul 23, 2021, 12:35:32 AM7/23/21
to Swift for TensorFlow,, Ravindra Sonkar
Thank you so much for your reply and it worked.
Very very thank you for your help it’s means a lot. 
This is last problem I had. Thank you again
Reply all
Reply to author
0 new messages