google / swift-jupyter

Apache License 2.0
619 stars 90 forks source link

[Colab] Unable to install Python packages in Swift notebook #108

Closed RahulBhalley closed 4 years ago

RahulBhalley commented 4 years ago

I cannot run the following code:

!pip --version

Not even % magic is working. I get the following error:

error: <Cell 13>:1:2: error: cannot find 'pip' in scope
!pip
 ^~~
BradLarson commented 4 years ago

You could try using the %system directive (described here) within the first cell to install any prerequisites for the notebook you need. That directive was primarily intended for installation of binaries needed before any Swift package could be installed, but might be useful for this as well.

Otherwise, SwiftAI has a shell() command implemented here that can run post-install commands like this via "/bin/pip".shell("install package"). I may not have the path and arguments right on that, but you get the general idea.

RahulBhalley commented 4 years ago

Thanks!