00a_intro_and_float.ipynb: public let np = Python.import("numpy")

Hi, why can not I import arbitrary Python modules and directly use them in Colab? and show error: error: module ‘Python’ has no member named ‘import’. How to fix it ? thanks.

I believe that this and the other issues you are encountering are due to the fact that you’re trying to use the course notebooks that were pegged for the 0.4 release with Colab, which is running the 0.9 release of the Swift for TensorFlow toolchain. You may want to instead try the continuously updated dev version of the notebooks here, which should be maintained to match the latest toolchains.

In this specific case, there was a namespace collision with another built-in module called Python, so we switched to using the PythonKit name for the module that provides Python interoperability. This had been the name of that module outside of the Swift for TensorFlow toolchain, so it made sense to align with that.

In the updated notebook, you’ll see the following to account for this:

#if canImport(PythonKit)
    import PythonKit
    import Python

Hi Bradlarson, thank you a lot. It works now as you said.

If you are available, could you have a hint how deal with my issue (with the first cell), which always come out of such OUTPUT with error.

%install-location $cwd/swift-install
%install ‘.package(path: “$cwd/FastaiNotebook_00_load_data”)’ FastaiNotebook_00_load_data

Installing packages:
.package(path: “/content/FastaiNotebook_00_load_data”)
With SwiftPM flags: []
Working in: /tmp/tmpjpgb_ama/swift-install
error: Error Domain=NSCocoaErrorDomain Code=260 “The file doesn’t exist.”
Install Error: swift-build returned nonzero exit code 1.