I have this file em.pyx
in the same folder as the Jupyter notebook where I try to import it but it is giving me the error
ImportError: No module named em
I've tried adding
import sys
sys.path.insert(0, 'name_of_directory_where_pyxfile_is')
or
sys.path.append('my/path/to/module/folder')
as suggested here and here, but I keep getting the same error. I've also created an empy __init__.py
file, but nothing.
EDIT: Then I added
import pyximport
pyximport.install()
before import em
, and now I get lots of errors from python 2.7 (I don't know why python2 since the compilation of pyx was made with python3 and the jupyter kernel is also set to Python3); the first three are:
ImportError Traceback (most recent call last)
<ipython-input-2-778b3d13b1ae> in <module>()
2 pyximport.install()
3
----> 4 import em1d
/home/me/.local/lib/python2.7/site-packages/pyximport/pyximport.pyc in load_module(self, fullname)
460 self.pyxbuild_dir,
461 build_inplace=self.inplace,
--> 462 language_level=self.language_level)
463 return module
464
/home/me/.local/lib/python2.7/site-packages/pyximport/pyximport.pyc in load_module(name, pyxfilename, pyxbuild_dir, is_package, build_inplace, language_level, so_path)
231 raise exc.with_traceback(tb)
232 else:
--> 233 exec("raise exc, None, tb", {'exc': exc, 'tb': tb})
234 return mod
235
EDIT2: Also, after running pyximport.install()
I get (None, None)