I'm facing a problem with Cython. I created the following two files in the same directory.
< sample.pyx >
print("hello world!")
< test.py >
import pyximport
pyximport.install()
import sample
When I run test.py, I got the error:
Traceback (most recent call last):
File "<ipython-input-15-e135bfea2262>", line 1, in <module>
runfile('C:/Users/itsez/Desktop/python/test.py', wdir='C:/Users/itsez/Desktop/python')
File "C:\Users\itsez\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "C:\Users\itsez\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 88, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "C:/Users/itsez/Desktop/python/test.py", line 3, in <module>
import sample
File "C:\Users\itsez\Desktop\python\pyximport.py", line 435, in load_module
File "C:\Users\itsez\Desktop\python\pyximport.py", line 225, in load_module
File "C:\Users\itsez\Desktop\python\pyximport.py", line 209, in load_module
File "C:\Users\itsez\Desktop\python\pyximport.py", line 180, in build_module
ImportError: Building module sample failed: ["SystemError: Parent module '' not loaded, cannot perform relative import\n"]
What am I doing wrong?