我正在尝试使用Cython。与让pyximport执行此操作不同,我使用setup.py和build。然而,每次我导入我的模块时,似乎都会调用pyximport。pyximport无法构建,一切都崩溃了。
我使用Spyder。在我的项目中没有单个对pyximport的引用,但是Spyder似乎并不关心并继续调用pyximport。
我从命令窗口(在Spyder之外)调用我的程序,并且它运行得非常好。
我该如何摆脱对pyximport的调用?还是其他事情正在发生?
我使用Spyder。在我的项目中没有单个对pyximport的引用,但是Spyder似乎并不关心并继续调用pyximport。
我从命令窗口(在Spyder之外)调用我的程序,并且它运行得非常好。
我该如何摆脱对pyximport的调用?还是其他事情正在发生?
import c_result
Traceback (most recent call last):
File "<ipython-input-2-3e92d1c50179>", line 1, in <module>
import c_result
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 458, in load_module
language_level=self.language_level)
File "C:\Users\xxxR\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 231, in load_module
raise exc.with_traceback(tb)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 215, in load_module
inplace=build_inplace, language_level=language_level)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 191, in build_module
reload_support=pyxargs.reload_support)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 185, in run
_build_ext.build_ext.run(self)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\command\build_ext.py", line 339, in run
self.build_extensions()
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 192, in build_extensions
ext.sources = self.cython_sources(ext.sources, ext)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 327, in cython_sources
self.mkpath(os.path.dirname(target))
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\cmd.py", line 338, in mkpath
dir_util.mkpath(name, mode, dry_run=self.dry_run)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\dir_util.py", line 74, in mkpath
"could not create '%s': %s" % (head, exc.args[-1]))
ImportError: Building module c_result failed: ["distutils.errors.DistutilsFileError: could not create 'C:\\Windows\\system32\\config\\systemprofile': Kan ikke opprette en fil når filen allerede finnes\n"]
sitecustomize.py
文件,并删除if HAS_PYXIMPORT:
下面的部分。 - Pierre de Buylls
返回什么?(它由 IPython 解释,并将列出目录,就像常规的 shell 命令一样)。 - Pierre de Buylc_result.*.pyd
在目录中,应该可以正确导入。Spyder会干扰sys.path
,你能打印一下吗?import sys; print(sys.path)
- Pierre de Buylpython36
的引用。该模块是使用Python 3.5编译的。你能否使用正确的Python版本重新编译它? - Pierre de BuylC:\Users\ac22376.ONEADR\AppData\Local\Continuum\Anaconda3\bin\python3.6
编译。我对Windows不够了解,无法推荐更高级的设置,就此告一段落。 - Pierre de Buyl