3

I'm trying to run some code python code in Google colab. This code uses some custom modules I wrote, some of which were written in cython. On my local machine, I'd normally compile the cython code first before running my main python script. What is the correct way of doing this on colab, if there is one? Right now, the script throws an error when it tries to import my cython modules. Specifically, I get the error

ImportError: model/cython_library/core.so: invalid ELF header

which makes sense, since the core.so file was compiled on my local machine instead of gcloud.

user360798
  • 31
  • 2
  • compile the module in colab then? – Marat Oct 27 '20 at 01:25
  • yeah, how would you do that? the only examples I can find on Google involve basically dumping the entire contents of all my modules into colab, something I'd prefer to avoid given the complexity of the code involved. – user360798 Oct 27 '20 at 01:28
  • Can you include how you currently compile the cython code? Is there any way to upload (or download) that code to collab (eg is it on github)? If you have it in collab, then you can compile it there. – jkr Oct 27 '20 at 01:43
  • Another, more complicated, way to do this, would be to compile your cython module as a [manylinux python wheel](https://github.com/pypa/manylinux) (a wheel file that can be installed on most linux distributions) and then install that wheel on google collab. – jkr Oct 27 '20 at 01:49
  • 2
    thanks a lot for the comment @jakub! I was compiling it in my shell using the command: python setup.py build_ext --inplace. I realised I can run the same command in colab by simply putting an exclamation in front. It looks like that solved the problem. – user360798 Oct 27 '20 at 01:51

0 Answers0