Swift: Python interoperabilty errors referencing programmer's computer

Created on 24 Aug 2019  路  5Comments  路  Source: tensorflow/swift

When I try to reference Python

import Python
let np = Python.import("numpy")

I get the following error that seems to reference Dan Zheng's computer path

Fatal error: 'try!' expression unexpectedly raised an error: Python exception: 
No module named 'numpy': file /path-to-dan-computer, line 683
2019-08-24 01:43:01.672188+0200 s4tf-test[18635:186541] 
Fatal error: 'try!' expression unexpectedly raised an error: Python exception: 
No module named 'numpy': filepath--to-dan-computer, line 683

This is from XCode 11 Beta, using August 10, 2019 XCode development snapshot, running on Mac (script) target.

FYI: I selected Disable Library Validation on Signing & Capabilities because I was getting an error :
dyld: Library not loaded: @rpath/libswiftPython.dylib Referenced from: /Users/myself/Library/Developer/Xcode/DerivedData/s4tf-test-amtswalwdixtlobpwpvowkbjzzne/Build/Products/Debug/s4tf-test Reason: no suitable image found. Did find: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2019-08-10-a.xctoolchain/usr/lib/swift/macosx/libswiftPython.dylib: code signature in (/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2019-08-10-a.xctoolchain/usr/lib/swift/macosx/libswiftPython.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

Most helpful comment

Thank you @dan-zheng I followed this guide https://github.com/tensorflow/swift/blob/master/Installation.md

Upon further observation my problem was that i have multiple versions of Python and i needed to pick the right one to load numpy.

Apologies.

All 5 comments

Development snapshot with the stdlib is built on Dan's computer

So, is there a way to get around this error? Not understanding why the issue is closed.

So, is there a way to get around this error? Not understanding why the issue is closed.

The issue is quite old now. Could you please share a reproducer program? Which toolchain are you using?

Thank you @dan-zheng I followed this guide https://github.com/tensorflow/swift/blob/master/Installation.md

Upon further observation my problem was that i have multiple versions of Python and i needed to pick the right one to load numpy.

Apologies.

No worries! If you're curious, our Python interoperability tutorial has some configuration examples, like setting the Python version via PYTHON_LIBRARY and debugging via PYTHON_LOADER_LOGGING=1.

Was this page helpful?
0 / 5 - 0 ratings