Search code examples
importjupytergoogle-colaboratorycython

Importing from .pyx file in google colab


I am trying to import from a .pyx file in google colab but I get the error: ModuleNotFoundError: No module named 'filename'

My current code is:

from google.colab import drive
drive.mount('/content/drive')
import sys
sys.path.append('/content/drive/My Drive/desiredPath')
from desiredModule import desiredClass

Any help would greatly be appreciated!


Solution

  • You cannot directly import pyx files, they must be compiled using Cython.

    See the cython docs on how to build a cython-based project.