我遇到了Cython的问题。我在同一目录中创建了以下两个文件。
< sample.pyx>
print("hello world!")
< test.py>
import pyximport
pyximport.install()
import sample
当我运行test.py时,我收到错误:
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"]
我做错了什么?